Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
839 views
in Technique[技术] by (71.8m points)

unit testing - Trying to run Android JUnit tests in Eclipse fails?

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).

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

[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

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....

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

ex:

public class TestappTest extends ActivityInstrumentationTestCase2<AppUnderTest> {

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

  public void testApp() {
      // Testcase
  }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...