0

Can't make Robotium work. It used to, but now always fails with an error:
Running tests Test running startedFinish Empty test suite.

My test draft:

public class MainActivityTest extends ActivityInstrumentationTestCase2 <MainActivity> {

private Solo solo;

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

@Override
protected void setUp() throws Exception {
    super.setUp();
    solo = new Solo(getInstrumentation(), getActivity());
}

@Override
protected void tearDown() throws Exception {
    super.tearDown();
    solo.finishOpenedActivities();
}

@Override
protected void runTest() throws Throwable {
    super.runTest();
}

}

build.gradle

    defaultConfig {
    applicationId "my.app"
    testInstrumentationRunner "android.test.InstrumentationTestRunner"
}

AndroidManifest.xml

<instrumentation
android:name="android.test.InstrumentationTestRunner"
android:targetPackage="my.app"/>

In Edit configurations for instrumentation runner I have android.test.InstrumentationTestRunner. Where's the problem?

shiryaeva
  • 75
  • 1
  • 8

1 Answers1

0

which i have figured out for empty test and started test finished test was that my run test was unable to call test method, to do so you have to prefix your MainActivity class method to test MainActivity method. e.g

Class MAinActivity extends Activity{ //Class A

  public void calculateSomething(){}

}

Class MAinActivityTest extends ActivityInstrumentationTestCase2 <MainActivity>{ //Class B - Test Class in your case MainActivityTest 

  @TestCalculate
  public void testCalculateSomething(){
        //Do your testing here
  }

}

Dont forgot the sequence of calling your main Activity Functions would be same as here in TestClass.

for more info please check Why is the Android test runner reporting "Empty test suite"?

Community
  • 1
  • 1
Fazal
  • 3,374
  • 1
  • 15
  • 20