Trying to run Android JUnit tests in Eclipse fails?

泄露秘密 提交于 2019-11-29 13:38:58

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

I had the same problem. The reason was the constructor - it somehow had a parameter like this:

public SearchActivityTest(Class<SearchActivity> activityClass) {
    super("com.example.app", SearchActivity.class);
}

But it should have no parameters like this:

public SearchActivityTest() {
    super("com.example.app", SearchActivity.class);
}

It worked for me.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!