Test run failed: Test run failed to complete. Expected 1 tests, received 0

Alex picture Alex · Jul 25, 2012 · Viewed 9.2k times · Source

I tried starting a JUnit test (robotium) for my app:

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

Manifest

 <instrumentation
    android:name="android.test.InstrumentationTestRunner"
    android:targetPackage="nix.android.contact" />

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <uses-librar

y android:name="android.test.runner" />
    </application>

When I try to run the test this is the error I get in the console:

Test run failed: Test run failed to complete. Expected 1 tests, received 0

I tried creating another test a different app (very simple app) and it works.

Answer

koljaTM picture koljaTM · Oct 10, 2012

I had this problem when I didn't have a no-args constructor.

public class MainActivityTest extends
    ActivityInstrumentationTestCase2<MainActivity_> {

public MainActivityTest() {
    super(MainActivity_.class);
}
...