我在网上看过所有的例子,看起来很简单。我有一个显示字符串的基本应用程序。我有一个在创建应用程序时创建的 Android JUnit 测试项目(eclipse 询问我是否要创建测试应用程序)。
当我运行测试应用程序(Run As --- Android JUnit)时,我在控制台中看到以下内容....
[2010-02-27 00:45:03 - SimpleCalculatorTest]在设备 emulator-5554 上启动检测 android.test.InstrumentationTestRunner [2010-02-27 00:45:12 - SimpleCalculatorTest]测试运行完成
我没有看到被调用的测试用例中的任何代码。 我的测试用例是一个扩展 ActivityInstrumentationTestCase2 的类。 DDMS 日志显示: 02-27 00:44:58.521: WARN/TestGrouping(1275): 无效的包: '' 找不到或没有测试
有什么想法吗?我什么都试过了....
最佳答案
如果您创建一个新的 ActivityInstrumentationTestCase2,那么您需要一个指向您要测试的类的默认构造函数。
例如:
public class TestappTest extends ActivityInstrumentationTestCase2<AppUnderTest> {
public TestappTest() {
super("my.package.app", AppUnderTest.class);
}
public void testApp() {
// Testcase
}
}
关于android - 尝试在 Eclipse 中运行 Android JUnit 测试失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2346734/