實際上,我想實現它使用下面的類在AndroidJunit測試運行UiAutomatorTestcase項目
- UIObject的
- UiSelector
- UiAutomatorTestcase
單擊並打開Android設備上的消息應用程序,然後在Eclipse中將其作爲AndroidJunit測試運行。
運行代碼時,我得到下面的異常
了java.lang.RuntimeException:存根!
我不明白我要去哪裏錯了。請讓我知道我們是否可以使用AndroidJuint Test項目來運行UiAutomatorTestcase測試套件。
下面是示例代碼和故障跟蹤
public class UiautomatorTest extends
ActivityInstrumentationTestCase2<MyMainActivity> {
UiAutomatorTestCase mUiAutomatorTestCase;
public UiautomatorTest() {
super(MyMainActivity.class);`enter code here`
// TODO Auto-generated constructor stub
}
@Override
protected void setUp() throws Exception {
// TODO Auto-generated method stub
super.setUp();
mUiAutomatorTestCase = new UiAutomatorTestCase();
}
public void testToOpenMessageApp() throws UiObjectNotFoundException {
UiObject message = new UiObject(
new UiSelector().description("Messaging"));
message.clickAndWaitForNewWindow();
UiObject composeMessage = new UiObject(
new UiSelector().description("compose"));
composeMessage.clickAndWaitForNewWindow();
UiObject typeMessage = new UiObject(
new UiSelector().description("Type Message"));
typeMessage.clickAndWaitForNewWindow();
mUiAutomatorTestCase.getUiDevice().pressHome();
}
}
堆棧跟蹤
java.lang.RuntimeException: Stub!
at mypackagename.UiAutomatorTestCase.<init>(UiAutomatorTestCase.java:5)
at mypackagename..setUp(UiautomatorTest.java:25)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:190)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:175)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:555)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1584)
你能發佈堆棧從logcat跟蹤? – mach
我附上了失敗跟蹤 –