Your SlideShare is downloading. ×
0
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Mobile automation uamobile
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Mobile automation uamobile

1,942

Published on

Published in: Technology
1 Comment
2 Likes
Statistics
Notes
No Downloads
Views
Total Views
1,942
On Slideshare
0
From Embeds
0
Number of Embeds
9
Actions
Shares
0
Downloads
17
Comments
1
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Автоматизация Тестирования Мобильных Приложений Андрей Дзыня
  • 2. Andrii DzyniaTest Engineer/Consultant/Trainer @adzynia http://adzynia.com
  • 3. СегодняПочему я начал заниматься автоматизациеймобильных приложений? Какие есть инструменты?Какие проблемы решены, а какие нет?
  • 4. Мой опыт
  • 5. Кто у нас в зале?
  • 6. Особенность мобильной разработки?
  • 7. Типы приложений?WebNativeHybridOpenGLFlash & FlexWidgets
  • 8. • Скорость• Дизайн• Возможности платформы• Кроссплатформенность
  • 9. Автоматизация UI API Integration Unit
  • 10. Какие бывают роботы?
  • 11. ИнструментыMultiplatform tools UI Automation, iPhone Android WebDriver, Native tools WebDriver, NativeDriver, NativeDriver, Robotium, Frank, TAF, KIF, calabash calabash Record’n’play
  • 12. Дорого и ненадежно
  • 13. Device Anywhere
  • 14. Бесплатно и ненадежно @Test public void testFindInROI() throws Exception { JButtons frame = new JButtons(); Screen scr = new Screen(); Match m = scr.wait("test-res/network.png", 10); scr.setRect(new Rectangle(m.x-9, m.y-10, m.w+10, m.h+11)); Match m2 = scr.doFind("test-res/network.png"); assertEquals(m, m2); frame.dispose(); }https://github.com/sikuli/sikuli
  • 15. Не очень дорого но и не нужно M-eux
  • 16. Бесплатноно могло быть и лучше
  • 17. Keep It Functional@implementation KIFTestScenario (EXAdditions)+ (id)scenarioToLogIn;{KIFTestScenario *scenario = [KIFTestScenario scenarioWithDescription:@"Test that auser can successfully log in."];[scenario addStep:[KIFTestStep stepToReset]];[scenario addStepsFromArray:[KIFTestStep stepsToGoToLoginPage]];[scenario addStep:[KIFTestStep stepToEnterText:@"user@example.com"intoViewWithAccessibilityLabel:@"Login User Name"]];[scenario addStep:[KIFTestStep stepToTapViewWithAccessibilityLabel:@"Log In"]];// Verify that the login succeeded[scenario addStep:[KIFTestStepstepToWaitForTappableViewWithAccessibilityLabel:@"Welcome"]];return scenario; }@end https://github.com/square/KIF
  • 18. UI Automation
  • 19. Код UI Automation// create a new accounttable.cells().firstWithName("twitter").tap();mainWindow = app.mainWindow();table = mainWindow.tableViews()[0];userName = table.cells().firstWithName("user name");userName.textFields()[0].setValue("mrfoobar");finish = table.cells().firstWithName("finish");finish.tap();
  • 20. https://github.com/alexvollmer/tuneup_jstest("my test", function(target, app) { { mainWindow = app.mainWindow(); tableViews = mainWindow.tableViews(); assertEquals(1, tableViews.length); table = tableViews[0]; assertEquals("First Name", table.groups()[0].staticTexts()[0].name()); assertEquals("Last Name", table.groups()[1].staticTexts()[0].name()); assertEquals("Fred", table.cells()[0].name()); assertEquals("Flintstone", table.cells()[1].name());}
  • 21. Jasminedescribe("Hello World App", function() {{ var target = UIATarget.localTarget(); function getLabel() { { return target.frontMostApp(). mainWindow().staticTexts()[0].value(); } it("should display "Hello World !" in the label after pressing the "Click Me :)" button", function() { target.frontMostApp(). mainWindow().buttons()["Click Me :)"].tap(); expect(getLabel()).toEqual("Hello World !"); });});
  • 22. Jasminehttps://github.com/pivotal/jasmine-iphonehttps://github.com/mczenko/UIAutomation-jasmine-iphonehttps://github.com/shaune/jasmine-ios-acceptance-testshttps://github.com/jhaynie/iphonesimhttps://github.com/robholland/WaxSim
  • 23. iOS Native Driver Java Test public void testNativeDriver() throws Exception { WebDriver driver = new IosNativeDriver(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); // Type user name WebElement userName = driver.findElement(By.placeholder("User Name")); userName.clear(); userName.sendKeys("NativeDriver"); }http://code.google.com/p/nativedriver
  • 24. Not maintainedhttp://code.google.com/p/nativedriverSome updateshttps://github.com/sonixlabs/nativedriverhttps://github.com/leandog/nativedriverRuby APIhttps://github.com/jarib/nativedriver-rb
  • 25. EPAM-Mobile-TAFhttps://github.com/EPAM-Systems/EPAM-Mobile-TAF
  • 26. TAF Java Code@BeforeClasspublic static void beforeAll() { logger = TAFLoggerFactory. getLogger(ProjectExampleSmokeTestSet.class); setUpAllTests();}@Test(timeout = test_timeout)@TestFixture(username=test_desktop_user, password=test_desktop_pass)public void isAuthenticateLogin() { expecteds = AppModel.HomeScreen.getScreenModel(); actuals = ScreenFactory.getInstance().getLoginScreen(). login(username, password).getScreenModel(); Assert.assertArrayEquals(expecteds, actuals);}
  • 27. Behavior DrivenFeature: Various scenarios that exercise different partsof FrankScenario: Scrolling to the bottom of the tableGiven I launch the appWhen I touch "Larry Stooge"And I touch "User Roles"Then I should not see "Returns"When I scroll to the bottom of the tableThen I should see "Returns"
  • 28. Step DefinitionWhen /^I touch the "([^"]*)" nav bar button$/do |mark| touch( "navigationButton marked:#{mark}" )end
  • 29. Frameworkshttps://github.com/robholland/icukehttps://github.com/moredip/Frankhttps://github.com/calabash/calabash-ioshttp://cukes.info/https://github.com/cucumber/cucumber-jvmhttps://github.com/baalexander/Mother-May-UI
  • 30. BDD is Behavior Driven not Test Steps Driven
  • 31. Jenkinshttps://wiki.jenkins-ci.org/display/JENKINS/iOS+Device+Connector+Plugin
  • 32. Android Testinghttp://developer.android.com/tools/testing/testing_android.html
  • 33. Using Android SDKНажатия на View• TouchUtils.tapView(view)Нажатия на кнопки• getInstrumentation().sendKeyDownUpSync(KeyEvent.KEYCODE_MENU)Ввод текста• sendKey(“some text”)
  • 34. Activity Test@UiThreadTestpublic void testAdd() { MainActivity main = (MainActivity) getActivity(); EditText val1Edit = (EditText) main.findViewById(R.id.EditText1); val1Edit.setText("3"); EditText val2Edit = (EditText) main.findViewById(R.id.EditText2); val2Edit.setText("4"); Button addButton = (Button) main.findViewById(R.id.ButtonAdd); addButton.performClick(); TextView resultText = (TextView) main.findViewById(R.id.Result); assertEquals("Result incorrect", resultText.getText(), "7");}
  • 35. В чем проблема? Очень частоНужно знать структуру приходится добавлятькода приложения Thread.sleep(3000)Большие приложения Тесты выполняютсяавтоматизировать очень долгоочень сложно
  • 36. Robotium APIgetCurrentActivity()clickOnButton(String regex)clickInList(int line)enterText(int index, String text)searchText(String regex)waitForText(), waitForActivity(), waitForView()clickOnMenuItem(String text)goBack(), goBackToActivity(String name)
  • 37. Robotiumpublic void testPreferenceIsSaved() throws Exception { solo.sendKey(Solo.MENU); solo.clickOnText("Preferences"); solo.clickOnText("Edit File Extensions"); Assert.assertTrue(solo.searchText("rtf")); solo.clickOnText("txt"); solo.clearEditText(2); solo.enterText(2, "robotium"); solo.clickOnButton("Save"); solo.goBack(); solo.clickOnText("Edit File Extensions"); Assert.assertTrue(solo.searchText("application/robotium")); } http://code.google.com/p/robotium/
  • 38. Robotium with WebViewprivate ExtSolo solo;public void setUp() throws Exception { super.setUp(); solo = new ExtSolo(getInstrumentation(), getActivity(), this.getClass().getCanonicalName(), getName());}public void test() { solo.clickOnHtmlElement(“userName”); solo.enterTextIntoHtmlElement(“User”, ”userName”); solo.htmlGoBack();} http://docs.testdroid.com/_pages/extsolo.html
  • 39. Robotium выводыАвтоматические jUnit 3ожидания Работает только сАвтоматический поиск однопроцесснымиView приложениямиАвтоматическое Требует базовое Activityпереключение на Activity для работыСам принимает решения,например scroll
  • 40. Запуск тестов in Parallel или in Cloudhttp://testdroid.com/product/testdroid-server http://testdroid.com/product/testdroid-cloud
  • 41. Jenkins https://wiki.jenkins-ci.org/display/JENKINS/Android+Emulator+Pluginhttps://wiki.jenkins-ci.org/display/JENKINS/Building+an+Android+app+and+test+project
  • 42. Helper Toolshttp://developer.android.com/tools/help/hierarchy-viewer.htmlhttp://developer.android.com/tools/help/monkey.htmlhttps://github.com/robomorphine/testrunner
  • 43. Android Native Driver Java Test private AndroidNativeDriver driver; @Override protected void setUp() { driver = getDriver(); } @Override protected void tearDown() { driver.quit(); } protected AndroidNativeDriver getDriver() { return new AndroidNativeDriverBuilder().withDefaultServer().build(); } private void startListViewActivity() { driver.startActivity("com.google.android.testing.nativedriver." + "simplelayouts.ListViewActivity"); } public void testClickListItems_scrollsGradually() { startListViewActivity(); for (String state : states) { driver.findElement(AndroidNativeBy.text(state)).click(); }} http://code.google.com/p/nativedriverhttps://github.com/alfredz/android-nativedriver
  • 44. ANDROID UI APIUiScrollable settingsItem = newUiScrollable(new UiSelector().className("android.widget.ListView"));UiObject about =settingsItem.getChildByText(new UiSelector().className("android.widget.LinearLayout"),"About tablet");about.click() http://developer.android.com/tools/testing/testing_ui.html http://developer.android.com/tools/help/uiautomator/index.html
  • 45. Monkey Runner Pythondevice = MonkeyRunner.waitForConnection()package = com.example.android.notepaddevice.wake()device.shell("am start -a android.intent.action.INSERT -tvnd.android.cursor.dir/contact -e name Vasya Pupkin -e phone 555-1111")device.startActivity(component="com.android.contacts/.TwelveKeyDialer")device.installPackage(d:NotePadTraining.apk)device.press(KEYCODE_MENU, MonkeyDevice.DOWN_AND_UP)device.type("asdsadsad") http://developer.android.com/tools/help/monkeyrunner_concepts.html
  • 46. Monkey Runner Extensiondef testViewFactory_TextView(self): attrs = {class: android.widget.EditText, text:mText: Button with ID} view = View.factory(attrs, None, -1) self.assertTrue(isinstance(view, EditText))https://github.com/dtmilano/AndroidViewClient
  • 47. Other Android Toolshttp://developer.android.com/tools/help/monkey.htmlhttps://github.com/calabash/calabash-androidhttps://github.com/eing/moethttp://www.ranorex.com/mobile-automation-testing/android-test-automation.htmlhttps://github.com/kaeppler/calculonhttps://github.com/pivotal/robolectrichttps://www.lesspainful.com/
  • 48. Demo
  • 49. For Web Applications
  • 50. Selenium WebDriverpublic void testGoogle() throws Exception { WebDriver driver = new AndroidDriver() or IPhoneDriver(); driver.get("http://www.google.com"); WebElement element = driver.findElement(By.name("q")); element.sendKeys("Cheese!"); element.submit(); driver.quit();}
  • 51. Сегодня узналиКакие есть инструменты для UIавтоматизации тестирования:• iOS приложений• Android приложенийКакие стоит использовать, а какие нет
  • 52. http://adzynia.com @adzynia me@adzynia.com

×