+ All Categories
Home > Mobile > Android UI Testing with uiautomator

Android UI Testing with uiautomator

Date post: 26-May-2015
Category:
Upload: jana-moudra
View: 1,000 times
Download: 5 times
Share this document with a friend
Description:
This presentation is about Android UI Testing with uiautomator library. Demo test available on github: https://github.com/Janamou/android-ui-test
Popular Tags:
26
Android UI Testing with uiautomator Jana Moudrá | @Janamou | +JanaMoudrá
Transcript
Page 1: Android UI Testing with uiautomator

Android UI Testingwith uiautomator

Jana Moudrá | @Janamou | +JanaMoudrá

Page 2: Android UI Testing with uiautomator

Me

Co-Founder at JuicymoGDG ČVUT Prague/GDG Prague

Web, Android, Design, Dart

about.me/janamou

Page 3: Android UI Testing with uiautomator

Motivation

Page 4: Android UI Testing with uiautomator

UI Testing

UI testing ensures that your application returns the correct UI output in response to a sequence

of user actions on a device.

http://developer.android.com/tools/testing/testing_ui.html

Page 5: Android UI Testing with uiautomator

UI Testing

No knowledge of implementation

Testing and implementation

separated

Page 6: Android UI Testing with uiautomator

Manual?

Time consumingNot repeatable

Error prone

Page 7: Android UI Testing with uiautomator

Manual?

Time consumingNot repeatable

Error prone

We want to automate

Page 8: Android UI Testing with uiautomator

Android?

Page 9: Android UI Testing with uiautomator

Android?uiautomator

Page 10: Android UI Testing with uiautomator

Android 4.1

Device

Tests in Java

Page 11: Android UI Testing with uiautomator

How to test

in 3 steps

Page 12: Android UI Testing with uiautomator

Create the App

1

Page 13: Android UI Testing with uiautomator

Prepare the Test

2

Page 14: Android UI Testing with uiautomator

Prepare the Test

Application is accessible

Application is on the device

Use uiautomatorviewer

Set development environment

Create the test

Page 15: Android UI Testing with uiautomator

Development environment

Java project

+JUnit + uiautomator.jar + android.jar

Page 16: Android UI Testing with uiautomator

Use uiautomatorviewer

Page 17: Android UI Testing with uiautomator

Create the Test

extend the

UiAutomatorTestCase class

Page 18: Android UI Testing with uiautomator

Use available classes

UiDeviceUiSelectorUiObject

UiCollectionUiScrollable

Page 19: Android UI Testing with uiautomator

UiSelector

UiObject threeButton = new UiObject(

new UiSelector().text("3"));

threeButton.click();

Page 20: Android UI Testing with uiautomator

UiSelector

UiObject urlForm = new UiObject(

new UiSelector()

.resourceId("com.android.browser:id/url"));

urlForm.setText("http://www.gug.cz");

getUiDevice().pressEnter();

Page 21: Android UI Testing with uiautomator

What can I do with UiObject?

Use gesturesRetrieve attributes

Set textNo manipulation

Page 22: Android UI Testing with uiautomator

We can use Asserts

assertEquals(threeButton.getText(), "3");

Page 23: Android UI Testing with uiautomator

Run the Test

3

Page 24: Android UI Testing with uiautomator

Run the Test

1) Build with Ant2) Push to device

3) Run the test

Page 25: Android UI Testing with uiautomator

DEMO

Page 26: Android UI Testing with uiautomator

Thank You!Questions???

about.me/janamou


Recommended