尝试为我的应用程序启动JUnit测试(robotium).
public class MainTest extends ActivityInstrumentationTestCase2<MainActivity> { private Solo solo; public MainTest() { super("nix.android.contact",MainActivity.class);// TODO Auto-generated constructor stub } protected void setUp() throws Exception { super.setUp(); solo = new Solo(getInstrumentation(),getActivity()); } public void AddContact() { solo.assertCurrentActivity("main",MainActivity.class); } }
表现
<instrumentation android:name="android.test.InstrumentationTestRunner" android:targetPackage="nix.android.contact" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <uses-library android:name="android.test.runner" /> </application>
当我尝试运行测试,进入控制台:
Test run Failed: Test run Failed to complete. Expected 1 tests,received 0
我尝试为其他应用程序(非常简单的应用程序)创建其他测试 – 工程.
谢谢
解决方法
当我没有no-args构造函数时,我遇到了这个问题.
public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActivity_> { public MainActivityTest() { super(MainActivity_.class); } ...