2016-04-11 17 views
0

我已經創建瞭如下的「UiAutometerTest」類來驗證我的UiAutomator API。junit.framework.AssertionFailedError:在Android Studio中未在UiAutomator中找到測試

公共類UiAutometerTest擴展InstrumentationTestCase {

private UiDevice device; 
@Override 
protected void setUp() throws Exception { 
    super.setUp(); 
    device = UiDevice.getInstance(getInstrumentation()); 
    device.pressHome(); 
    // Wait for the Apps icon to show up on the screen 
    device.wait(Until.hasObject(By.desc("Apps")), 3000); 
    UiObject2 appsButton = device.findObject(By.desc("Apps")); 
    appsButton.click(); 
    // Wait for the ResMed icon to show up on the screen 
    device.wait(Until.hasObject(By.text("My Application")), 3000); 
    UiObject2 SplusApp = device.findObject(By.text("My Application")); 
    SplusApp.click(); 
    assertTrue(true); 
} 

}


在測試運行,我得到以下異常

運行測試 試運行開始 junit.framework.AssertionFailedError :在com.example.ajitp.myapplication.UiAutometerTest中找不到測試 在android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191) 在android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176) 在android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:555) 在android.app.Instrumentation $ InstrumentationThread.run(Instrumentation.java:1889)

完成


在此先感謝

回答

0

JUnit3測試以 「test」 開始的方法 - 例如:public void testFoo()

您看到的錯誤是因爲測試運行器沒有找到任何看起來像測試的方法。它會消失,一旦你添加一些。

注意:這不是特定於UI Automator的。這可能會發生在任何JUnit測試中。

相關問題