实际上,我想实现它使用下面的类在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
我附上了失败跟踪 –