【问题标题】:Robotium testing: empty test suite机器人测试:空测试套件
【发布时间】:2015-07-15 11:35:50
【问题描述】:

无法让 Robotium 工作。它曾经是,但现在总是失败并出现错误:
Running tests Test running startedFinish Empty test suite.

我的测试草稿:

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"/>

Edit configurations 中,仪表运行器我有android.test.InstrumentationTestRunner。问题出在哪里?

【问题讨论】:

    标签: android automated-tests robotium


    【解决方案1】:

    我已经弄清楚空测试并开始测试完成测试是我的运行测试无法调用测试方法,为此您必须将 MainActivity 类方法添加到 测试 MainActivity 方法。 例如

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

    不要忘记调用主 Activity 函数的顺序与此处在 TestClass 中的相同。

    更多信息请查看 Why is the Android test runner reporting "Empty test suite"?

    【讨论】:

      猜你喜欢
      • 2017-01-28
      • 2017-04-25
      • 1970-01-01
      • 2023-03-20
      • 2017-07-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-05
      相关资源
      最近更新 更多