Bri*_*ian 11 eclipse android unit-testing
我刚开始尝试在基本上是我的第一个Android应用程序中设置一些单元测试.我有一段时间为此寻找资源,但最终还是能够把我希望的正确道路向前推进.
首先,这就是我所做的.
在Eclipse中,我右键单击了我想为其创建测试项目的项目.我选择了AndroidTools - > New Test Project我填写了必要的信息,为新项目选择../MyApp/tests的位置,并选择MyApp作为要测试的项目.其他一切都被保留为默认值.
在执行此操作时,我收到以下错误:
[2011-04-01 08:13:02 - WPMSTest] R.java手动修改!恢复生成的版本!
但一切似乎都没问题.我的tests文件夹中有一个新的源代码树.
所以我尝试通过RunAs - > Android jUnit test来执行它(首先在硬件上,然后在模拟器上).
在两次运行中,我在我的eclipse控制台中收到了以下内容:
[2011-04-01 08:23:04 - WPMSTest]在设备模拟器上启动检测android.test.InstrumentationTestRunner-5554
[2011-04-01 08:23:04 - WPMSTest]无法启动测试
我的两个清单文件:
WPMSTest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.WPMS.test"
  android:versionCode="1"
  android:versionName="1.0">
<instrumentation android:targetPackage="com.WPMS" android:name="android.test.InstrumentationTestRunner" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
<uses-library android:name="android.test.runner" />
</application>
WPMS:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.WPMS"
  android:versionCode="1"
  android:versionName="1.0">
<application android:label="@string/app_name" android:icon="@drawable/ic_launcher_wpms">
    <activity android:name=".WPMS"
              android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>    
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> 
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
我希望有人之前见过这样的事情,并且可以解释我做错了什么.如果您需要更多文件,请告诉我,我一定会发布.
谢谢!
Bri*_*ian 15
我在测试项目中错过了一个TestSuite.一旦我的AllTests类扩展了TestSuite,我就错过了.
| 归档时间: | 
 | 
| 查看次数: | 11383 次 | 
| 最近记录: |