Want to learn how to UI test iOS and Android apps? In this talk, we’ll explore the latest iOS and Android UI testing techniques to create automated UI tests.
hit record to auto- generate your UI test code as you run your app TIP: Swift 2.0 has a new @testable annotation which exposes internal methods to your tests so you don’t have to mark methods public just for testing anymore. For example: @testable import <ClassUnderTest>
new process. It can also terminate your app. It’s also the starting point for finding elements DEFINITION: XCUIApplication is a proxy to your application.
UI DEFINITION: XCUIElement is a proxy for elements in your app. It’s made of a type (button, cell, window, etc) and an identifier (accessibility identifier, label, title, etc). These types and identifiers are used by queries to find your elements. Elements are found with queries which is a combination of type and identifier Identifier Element Query Type
elements. A query must resolve to a unique element. A non- match or multiple-match will result in a test failure. Identifier Element Query (collection of button types) Query (collection of nav bar types) Filter to find descendant element(s)
are visible to accessibility - tested apps are 508-compliant! Accessibility Inspector allows you to view the accessibility data of UI elements. Open the inspector by right-clicking Xcode icon, Open Developer Tool, and select Accessibility Inspector. View accessibility data by running your app, hover the cursor over an element and toggle Command + F7 .
Library in SDK Manager 2) Setup Gradle dependencies https://developer.android.com/tools/testing-support-library/index.html#setup 3) Setup folder structure - UI tests are created in src/androidTest
ViewMatcher or find an adapter-backed view with an ObjectMatcher 2) Perform a user action on the view with a ViewAction (tap, input text, etc) 3) Assert the state of the UI with a ViewAssertion https://developer.android.com/training/testing/ui-testing/espresso-testing.html#accessing-ui-components
an adapter-backed view with an ObjectMatcher 2) Perform a user action on the view with a ViewAction (tap, input text, etc) 3) Assert the state of the UI with a ViewAssertion ViewMatcher ObjectMatcher http://hamcrest.org/
an adapter-backed view with an ObjectMatcher 2) Perform a user action on the view with a ViewAction (tap, input text, etc) 3) Assert the state of the UI with a ViewAssertion ViewAction
an adapter-backed view with an ObjectMatcher 2) Perform a user action on the view with a ViewAction (tap, input text, etc) 3) Assert the state of the UI with a ViewAssertion Add Assertions to verify state changes or expected behavior ViewAssertion
navigate through your entire UI every single time. You can launch an activity and configure state in @Before • If you can test things without the UI test them without the UI because firing up the UI is expensive • Feed your networking stack mock data (Mocktrofit)