尝试在Eclipse无法运行Android JUnit测试? [英] Trying to run Android JUnit tests in Eclipse fails?

查看:299
本文介绍了尝试在Eclipse无法运行Android JUnit测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到了网络上所有的例子,似乎真正的简单。我有一个最基本的应用程序,显示字符串。我有当应用程序正在创建(日食问我是否想创建一个测试应用程序),我创建了AA的Andr​​oid JUnit测试项目。

I have seen all the examples on the web and it seems real simple. I have a bare-bones app that displays a string. I have a a Android JUnit test project that I created when the app was being created (eclipse asked if I wanted to create a test app).

当我运行测试程序(运行方式--- Android的JUnit的),我看到下面的控制台....

When I run the test app (Run As --- Android JUnit) I see the following in the console....

[2010-02-27○时45分03秒 - SimpleCalculatorTest]启动仪器android.test.InstrumentationTestRunner在设备模拟器-5554 [2010-02-27○点45分12秒 - SimpleCalculatorTest]测试运行完整的

[2010-02-27 00:45:03 - SimpleCalculatorTest]Launching instrumentation android.test.InstrumentationTestRunner on device emulator-5554 [2010-02-27 00:45:12 - SimpleCalculatorTest]Test run complete

我看不出有任何的code在测试用例被调用。 我的测试用例是扩展ActivityInstrumentationTestCase2一类。 DDMS日志显示: 02-27 00:44:58.521:WARN / TestGrouping(1275):无效的包:无法找到或没有测试

I do not see any of the code in the testcase being called. My testcase is a class that extends ActivityInstrumentationTestCase2. DDMS log shows : 02-27 00:44:58.521: WARN/TestGrouping(1275): Invalid Package: '' could not be found or has no tests

任何想法?我已经尝试了一切......

Any ideas? I have tried everything....

推荐答案

如果您创建一个新的ActivityInstrumentationTestCase2那么你需要一个默认的构造函数指向要测试的类。

If you create a new ActivityInstrumentationTestCase2 then you need a default constructor that points to the class that you want to test.

例如:

public class TestappTest extends ActivityInstrumentationTestCase2<AppUnderTest> {

  public TestappTest() {
    super("my.package.app", AppUnderTest.class);
  }

  public void testApp() {
      // Testcase
  }
}

这篇关于尝试在Eclipse无法运行Android JUnit测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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