nik*_*nik 10 junit android unit-testing ddms
我在网上看到了所有的例子,看起来很简单.我有一个显示字符串的简单应用程序.我有一个我在创建应用程序时创建的Android JUnit测试项目(eclipse询问我是否要创建测试应用程序).
当我运行测试应用程序(运行方式 - Android JUnit)时,我在控制台中看到以下内容....
[2010-02-27 00:45:03 - SimpleCalculatorTest]在设备模拟器-5554上启动检测android.test.InstrumentationTestRunner [2010-02-27 00:45:12 - SimpleCalculatorTest]测试运行完成
我没有看到测试用例中的任何代码被调用.我的测试用例是一个扩展ActivityInstrumentationTestCase2的类.DDMS日志显示:02-27 00:44:58.521:WARN/TestGrouping(1275):无效的包:''找不到或没有测试
有任何想法吗?我试过一切......
小智 10
如果您创建一个新的ActivityInstrumentationTestCase2,那么您需要一个指向要测试的类的默认构造函数.
例如:
public class TestappTest extends ActivityInstrumentationTestCase2<AppUnderTest> {
  public TestappTest() {
    super("my.package.app", AppUnderTest.class);
  }
  public void testApp() {
      // Testcase
  }
}
我有同样的问题.原因是构造函数 - 它以某种方式有这样的参数:
public SearchActivityTest(Class<SearchActivity> activityClass) {
    super("com.example.app", SearchActivity.class);
}
但它应该没有这样的参数:
public SearchActivityTest() {
    super("com.example.app", SearchActivity.class);
}
它对我有用.
| 归档时间: | 
 | 
| 查看次数: | 6801 次 | 
| 最近记录: |