是否有Android 2.1系统与ActivityInstrumentationTestCase2问题? [英] Are there problems with ActivityInstrumentationTestCase2 in Android 2.1?

查看:203
本文介绍了是否有Android 2.1系统与ActivityInstrumentationTestCase2问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经设置了所有的单元测试用例为我的Andr​​oid应用程序现在我也想这样做功能测试后。但我encouter一个问题。由于我的深化发展的的HTC Legend,我可以,现在,只有使用Android平台高达2.1。但在某些方面似乎在 ActivityInstrumentationTestCase2 将无法工作。

 公共SupplierSelectoinTest(){
    超(com.sap.catalogue.activities,SupplierSelection.class);
}

这个简单的一块code的给我下面的错误,当我尝试运行测试:

 了java.lang.RuntimeException:无法解析的活动:意向{行动= android.intent.action.MAIN FLG = 0x10000000的CMP = com.sap.catalogue.activities / COM。 sap.catalogue.activities.SupplierSelection}
在android.app.Instrumentation.startActivitySync(Instrumentation.java:371)
在android.test.InstrumentationTestCase.launchActivityWithIntent(InstrumentationTestCase.java:120)
在android.test.InstrumentationTestCase.launchActivity(InstrumentationTestCase.java:98)
在android.test.ActivityInstrumentationTestCase2.getActivity(ActivityInstrumentationTestCase2.java:87)
在com.sap.catalogue.test.acceptance.SupplierSelectoinTest.setUp(SupplierSelectoinTest.java:27)
在android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
在android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
在android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:430)
在android.app.Instrumentation $ InstrumentationThread.run(Instrumentation.java:1447)

我经历了所有教程阅读和我得到了它是,它应该工作,但事实并非如此。无论如何,当我切换到Android 2.2(这是现在还没有解决)我用的是新的构造函数,在这里我只需要在活动类手,而不是PKG串模拟器运行的测试,而抱怨。

但必须有一种方式来获得Android 2.1的运行这个!

除了
这是我的两个文件的Manifest.xml。第一个,是应用程序本身的之一。另一种是在测试项目中的一个。

应用程序的Manifest.xml

 <?XML版本=1.0编码=UTF-8&GT?;
<清单的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
      包=com.sap.catalogue
      安卓版code =1
      机器人:=的versionName1.0>
    <应用机器人:图标=@绘制/图标机器人:标签=@字符串/ APP_NAME>
        <活动机器人:名字=目录
                  机器人:标签=@字符串/ APP_NAME>
            &所述;意图滤光器>
                <作用机器人:名字=android.intent.action.MAIN/>
                <类机器人:名字=android.intent.category.LAUNCHER/>
            &所述; /意图滤光器>
        < /活性GT;    <活动机器人:名字=。activities.CategoryBrowser>< /活性GT;<活动机器人:activities.ProductDetailsNAME =>< /活性GT;
<活动机器人:名字=。activities.ProductSearch>< /活性GT;
<活动机器人:名字=。activities.ProductView>< /活性GT;
<活动机器人:名字=。activities.SupplierSelection>< /活性GT;< /用途>
    <采用-SDK安卓的minSdkVersion =7/><使用许可权的android:NAME =android.permission.INTERNET对>< /使用许可权>
< /清单>

测试的Manifest.xml

 <?XML版本=1.0编码=UTF-8&GT?;
<清单的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
      包=com.sap.catalogue.test
      安卓版code =1
      机器人:=的versionName1.0>
    <应用机器人:图标=@绘制/图标机器人:标签=@字符串/ APP_NAME>    <使用库机器人:名字=android.test.runner/>
    < /用途>
    <采用-SDK安卓的minSdkVersion =7/>
    <仪器仪表机器人:targetPackage =com.sap.catalogue机器人:名字=android.test.InstrumentationTestRunner/>< /清单>


解决方案

使用顶层包名。

 公共SupplierSelectoinTest(){
    超(com.sap.catalogue,SupplierSelection.class);
}

After I have set up all the unit test cases for my android application I now also want to do functional testing. But I encouter one problem. As I am developping for the HTC Legend I can, by now, only use android platforms up to 2.1. But in some way it seems that the ActivityInstrumentationTestCase2 won't work.

public SupplierSelectoinTest() {
    super("com.sap.catalogue.activities", SupplierSelection.class);
}

This simple piece of code gives me the following error, when I try to run the test:

java.lang.RuntimeException: Unable to resolve activity for: Intent { act=android.intent.action.MAIN flg=0x10000000 cmp=com.sap.catalogue.activities/com.sap.catalogue.activities.SupplierSelection }
at android.app.Instrumentation.startActivitySync(Instrumentation.java:371)
at android.test.InstrumentationTestCase.launchActivityWithIntent(InstrumentationTestCase.java:120)
at android.test.InstrumentationTestCase.launchActivity(InstrumentationTestCase.java:98)
at android.test.ActivityInstrumentationTestCase2.getActivity(ActivityInstrumentationTestCase2.java:87)
at com.sap.catalogue.test.acceptance.SupplierSelectoinTest.setUp(SupplierSelectoinTest.java:27)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:430)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1447)

I read through all tutorials and all I get out of it is, that it should work but it doesn't. Anyway, when I switch to android 2.2 (which is no solution for now) and I use the new constructor, where I only need to hand in the activity class and not the pkg string the emulator will run the tests without complaining.

But there has to be a way to get this running in android 2.1!

In addition These are my two Manifest.xml files. The first one, is the one of the application itself. The other one is the one of the test project.

Application Manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.sap.catalogue"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".Catalogue"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    <activity android:name=".activities.CategoryBrowser"></activity>

<activity android:name=".activities.ProductDetails"></activity>
<activity android:name=".activities.ProductSearch"></activity>
<activity android:name=".activities.ProductView"></activity>
<activity android:name=".activities.SupplierSelection"></activity>

</application>
    <uses-sdk android:minSdkVersion="7" />

<uses-permission android:name="android.permission.INTERNET"></uses-permission>
</manifest> 

Test Manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.sap.catalogue.test"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/app_name">

    <uses-library android:name="android.test.runner" />
    </application>
    <uses-sdk android:minSdkVersion="7" />
    <instrumentation android:targetPackage="com.sap.catalogue" android:name="android.test.InstrumentationTestRunner" />

</manifest> 

解决方案

Use the top level package name.

public SupplierSelectoinTest() {
    super("com.sap.catalogue", SupplierSelection.class);
}

这篇关于是否有Android 2.1系统与ActivityInstrumentationTestCase2问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆