-2
testAYLogout()
을 인스턴스화하고 응용 프로그램을 실행하려고하면 testAXEndTrip()
도 실행됩니다. 왜 그런가요? 당신은 Testing Support Library를 사용해야합니다uiautomator에서 상속을 사용할 수 있습니까? 그렇다면 어떻게?
public class ApplicationTest extends UiAutomatorTestCase {
public void testAYLogout() throws RemoteException, UiObjectNotFoundException {
//Get the device state
UiDevice myDevice = getUiDevice();
//menu button
UiObject menuButton = new UiObject(new UiSelector().className(android.widget.ImageButton.class.getName()).index(0));
//logout button
UiObject logoutButton = new UiObject(new UiSelector().className(android.widget.CheckedTextView.class.getName()).text("Logout"));
//yes button
UiObject yesButton = new UiObject(new UiSelector().className(android.widget.Button.class.getName()).text("Yes"));
//no button
UiObject noButton = new UiObject(new UiSelector().className(android.widget.Button.class.getName()).text("No"));
UiObject loginText = new UiObject(new UiSelector().className(android.widget.TextView.class.getName()).text("Login"));
if (!myDevice.isScreenOn()) {
myDevice.wakeUp();
}
//click menu button and wait for new window
menuButton.clickAndWaitForNewWindow();
assertTrue(logoutButton.exists());
//click logout
logoutButton.clickAndWaitForNewWindow();
//click no
noButton.clickAndWaitForNewWindow();
menuButton.clickAndWaitForNewWindow();
logoutButton.clickAndWaitForNewWindow();
//click yes button
yesButton.clickAndWaitForNewWindow();
assertTrue(loginText.exists());
}
public void testAXEndTrip() throws RemoteException, UiObjectNotFoundException {
//get device
UiDevice myDevice = getUiDevice();
//pick up location feild
UiObject okButton = new UiObject(new UiSelector().className(android.widget.Button.class.getName()).text("Ok").index(0));
//end trip button
UiObject endTripButton = new UiObject(new UiSelector().className(android.widget.Button.class.getName()).text("END TRIP").index(1));
//no button
UiObject noButton = new UiObject(new UiSelector().className(android.widget.Button.class.getName()).text("No"));
//yes button
UiObject yesButton = new UiObject(new UiSelector().className(android.widget.Button.class.getName()).text("Yes"));
//submit button
UiObject submitButton = new UiObject(new UiSelector().className(android.widget.Button.class.getName()).text("Submit"));
//rate button
UiObject rateButton = new UiObject(new UiSelector().className(android.widget.ImageButton.class.getName()).index(4));
//feedback field
UiObject feedback = new UiObject(new UiSelector().className(android.widget.EditText.class.getName()).index(1));
//map
UiObject map = new UiObject(new UiSelector().className(android.view.View.class.getName()).index(0));
//wake up device if screen is off
if (!myDevice.isScreenOn())
myDevice.wakeUp();
rateButton.waitForExists(5000);
rateButton.clickAndWaitForNewWindow();
feedback.setText("ride or die ma niguh");
submitButton.clickAndWaitForNewWindow();
assertTrue(map.exists());
}
}
다음이 내 메인 클래스
public class MainTest extends ApplicationTest{
public static void TestMain() throws RemoteException, UiObjectNotFoundException {
MainTest login = new MainTest();
login.testAYLogout();
}
}
나는 이미 선생님과 내 응용 프로그램이 실행 중이며 문제가 없습니다. 안드로이드가 java이기 때문에 상속을 사용할 수 있습니까? –
물론 가능합니다. 그것을 보여주기 위해 편집 됨. –
내가 도움 녀석에게 어디서 잘못했는지 알아 냈습니다. –