Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Автоматизация тестирования мобильных приложений

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on. →

Автоматизация тестирования мобильных приложений

Avatar for Alexey Emelin

Alexey Emelin

May 17, 2016

Other Decks in Programming

Transcript

  1. Android layouts Мобильные приложения 16 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:id="@+id/text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello, I am a TextView" /> <Button android:id="@+id/button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello, I am a Button" /> </LinearLayout>
  2. Android layouts Мобильные приложения 17 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/

    android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:id="@+id/text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello, I am a TextView" />
  3. iOS .xib .storyboard Мобильные приложения 18 <?xml version="1.0" encoding="UTF-8" standalone="no"?>

    <document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6245" systemVersion="13F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none"> <dependencies> <development version="5000" identifier="xcode"/> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6238"/> </dependencies> <objects> <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/> <tableViewCell contentMode="scaleToFill" selectionStyle="blue" indentationWidth="10" id="7DT-rP-zUI" customClass="CurrencyCell"> <rect key="frame" x="0.0" y="0.0" width="320" height="44"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" heightSizable="YES"/> <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="7DT-rP-zUI" id="11t-pC-dqN"> <rect key="frame" x="0.0" y="0.0" width="320" height="43"/>
  4. iOS .xib .storyboard Мобильные приложения 19 <objects> <placeholder placeholderIdentifier="IBFilesOwner" id="-1"

    userLabel="File's Owner"/> <tableViewCell contentMode="scaleToFill" selectionStyle="blue" indentationWidth="10" id="7DT-rP-zUI" customClass="CurrencyCell"> <rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
  5. Windows XAML Мобильные приложения 20 <Grid ShowGridLines="True" Margin="12,0,12,0"> <Grid.RowDefinitions> <RowDefinition

    Height="auto" /> <RowDefinition Height="auto" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <TextBox Text="1st row 1st column" TextWrapping="Wrap" Grid.Column="0" Grid.Row="0" /> <TextBox Text="3rd row 1st column" TextWrapping="Wrap" Grid.Column="0" Grid.Row="2" /> <Button Content="1st row 2nd column" FontSize="17" Grid.Column="1" Grid.Row="0" /> <Button Content="3rd row 2nd column" FontSize="17" Grid.Column="1" Grid.Row="2" /> </Grid>
  6. Windows XAML Мобильные приложения 21 <TextBox Text="1st row 1st column"

    TextWrapping="Wrap" Grid.Column="0" Grid.Row="0" /> <TextBox Text="3rd row 1st column" TextWrapping="Wrap" Grid.Column="0" Grid.Row="2" /> <Button Content="1st row 2nd column" FontSize="17" Grid.Column="1" Grid.Row="0" /> <Button Content="3rd row 2nd column" FontSize="17" Grid.Column="1" Grid.Row="2" />
  7. UiAutomator* Не ограничивается рамками одного приложения Тестирует по принципу black-box

    Поддерживается Android 4.3+ Базовые инструменты для функционального тестирования 27 * http://developer.android.com/intl/ru/training/testing/ui-testing/uiautomator-testing.html
  8. UiAutomator Базовые инструменты для функционального тестирования 28 public void testTwoPlusThreeEqualsFive()

    { mDevice.findObject(new UiSelector().resourceId("two")).click(); mDevice.findObject(new UiSelector().resourceId("plus")).click(); mDevice.findObject(new UiSelector().resourceId("three")).click(); mDevice.findObject(new UiSelector().resourceId("equals")).click(); UiObject result = mDevice.findObject(By.res(PACKAGE, "result")); assertEquals("5", result.getText()); }
  9. Espresso* Ограничивается рамками одного приложения Тестирует по принципу white-box Поддерживается

    Android 2.2+ Базовые инструменты для функционального тестирования 29 * http://developer.android.com/intl/ru/training/testing/ui-testing/espresso-testing.html
  10. Espresso Базовые инструменты для функционального тестирования 30 public void testGridView()

    { onView(withId(R.id.later_button)).perform(click()); onData(anything()).inAdapterView(allOf(withId(R.id.gridview), isDisplayed())).atPosition(2) .check(matches(isDisplayed())) .perform(click()); }
  11. UI Automation* Тесты на JavaScript Поддерживает сложные жесты Больше не

    поддерживается Apple Базовые инструменты для функционального тестирования 32 * https://developer.apple.com/library/tvos/documentation/DeveloperTools/Conceptual/InstrumentsUserGuide/UIAutomation.html
  12. UI Automation Базовые инструменты для функционального тестирования 33 test("Initial screen",

    function(target, app) { mainWindow = app.mainWindow(); table = mainWindow.tableViews()[0]; userName = table.cells().firstWithName("user name"); assertNotNull(userName, "No username field found"); userName.textFields()[0].setValue("mrfoobar"); assertEquals(4, table.cells().length); });
  13. Xcode UI Testing* Тесты на нативном swift Не поддерживает сложные

    жесты Быстрый Базовые инструменты для функционального тестирования 34 * https://developer.apple.com/videos/play/wwdc2015/406/
  14. Xcode UI Testing Базовые инструменты для функционального тестирования 35 func

    testShowElements() { let app = XCUIApplication() app.buttons["show elements"].tap() XCTAssertEqual(app.tables.count, 1) let table = app.tables.elementAtIndex(0) let expectedNumberOfElements: UInt = 118 XCTAssertEqual(table.cells.count, expectedNumberOfElements) }
  15. Coded UI Test Базовые инструменты для функционального тестирования 37 public

    void AssertMethod1() { #region Variable Declarations XamlEdit uITextBoxEdit = this.UIApp1Window.UITextBoxEdit; #endregion Assert.AreEqual(this.AssertMethod1ExpectedValues.UITextBoxEditText, uITextBoxEdit.Text); }
  16. Coded UI Test Базовые инструменты для функционального тестирования 38 [TestMethod]

    public void CodedUITestMethod1() { XamlWindow myAppWindow = XamlWindow.Launch("ed85f6ff-2fd1-4ec5-9eef-696026c3fa7b_cyrqexqw8cc7c! App"); Gesture.Tap(this.UIMap.UIApp1Window.UIButtonButton); this.UIMap.AssertMethod1(); }
  17. Calabash* Разрабатывается Xamarin Android и iOS Связка с Cucumber Тесты

    на Gherkin или Ruby Принцип white-box Кроссплатформенные инструменты 47 * http://calaba.sh/
  18. Cucumber* BDD (Behaviour Driven Development) 1. Фичи (сценарии) 2. Степы

    3. Тестирование Кроссплатформенные инструменты 51 * https://cucumber.io
  19. Тесты на Gherkin Кроссплатформенные инструменты 52 Feature: Credit card validation.

    Credit card numbers must be exactly 16 characters. Scenario: Credit card number is too long Given I try to validate a credit card number that is 17 characters long Then I should see the error message "Credit card number is too long."
  20. Степы на ruby Кроссплатформенные инструменты 53 Given(/^I try to validate

    a credit card number that is (\d+) characters long$/) do |number_of_digits| touch("textField marked:'CreditCardNumberField'") wait_for_keyboard keyboard_enter_text("9" * number_of_digits.to_i) touch("button marked:'Validate'") end
  21. Степы на ruby Кроссплатформенные инструменты 54 Then(/^I should see the

    error message "(.*?)"$/) do |error_message| text_view = query("textView marked:'ErrorMessagesField' {text CONTAINS '#{error_message}'}") raise "The error message '#{error_message}' is not visible in the View." unless text_view.any? end
  22. White-box Кроссплатформенные инструменты 55 public class MainActivity extends Activity {

    public void backdoorFoo(String baz) { Log.w(TAG, String.format("backdoor value of '%s'", baz)); } } Приложение: Тест: backdoor "backdoorFoo", "the value of baz" Backdoor* * https://developer.xamarin.com/guides/testcloud/calabash/working-with/backdoors/
  23. Appium* Разрабатывается Sauce Labs Android и iOS Реализует Webdriver API

    Тесты почти на любом языке программирования Принцип black-box Кроссплатформенные инструменты 56 * http://appium.io/
  24. Тесты почти на любом языке программирования Java C# Ruby Python

    Javascript Haskell php perl Кроссплатформенные инструменты 61
  25. Пример на java Кроссплатформенные инструменты 62 @Test public void addContact(){

    WebElement el = drvr.findElement(By.xpath(".//*[@text='Add Contact']")); el.click(); List<AndroidElement> l = drvr.findElementsByClassName("EditText"); l.get(0).sendKeys(«Some Name"); drvr.swipe(100, 500, 100, 100, 2); drvr.findElementByXPath(".//*[@text='Save']").click(); }
  26. Итого Автотесты на мобильные приложения нужны ̼Контроль качества ̼Частые релизы

    Выбор инструмента за вами ̼Разработчик - Xcode UI Testing, Espresso ̼QA - Appium ̼Менеджер + QA - Calabash 65
  27. Инфраструктура для устройств Бонус 67 selenium hub appium android sdk

    docker appium android sdk docker appium android sdk docker appium android sdk docker udev test
  28. Инфраструктура для эмуляторов Бонус 68 selenium hub appium android sdk

    docker test /dev/kvm:/dev/kvm emulator-x86 appium android sdk docker emulator-x86 appium android sdk docker emulator-x86 appium android sdk docker emulator-x86 /tmp/.X11-unix:/tmp/.X11-unix:ro
  29. Инфраструктура Бонус 69 selenium hub appium android sdk docker test

    /dev/kvm:/dev/kvm emulator-x86 appium android sdk docker emulator-x86 appium android sdk docker emulator-x86 appium android sdk docker emulator-x86 /tmp/.X11-unix:/tmp/.X11-unix:ro appium android sdk docker appium android sdk docker appium android sdk docker appium android sdk docker udev