xamarin ui test and xamarin test cloud

of 28 /28
Xamarin UI Test And Xamarin Test Cloud Gavin Bryan (Freelance Certified Xamarin Developer)

Upload: emanuel-amiguinho

Post on 06-Apr-2017

74 views

Category:

Presentations & Public Speaking


3 download

TRANSCRIPT

Page 1: Xamarin UI Test And Xamarin Test Cloud

Xamarin UI Test And

Xamarin Test Cloud

Gavin Bryan (Freelance Certified Xamarin Developer)

Page 2: Xamarin UI Test And Xamarin Test Cloud

Overview

• Xamarin UI Test• How and where Xamarin UI Tests can be run• Xamarin Test Cloud

Page 3: Xamarin UI Test And Xamarin Test Cloud

What is Xamarin UI Test?

• Automation Test Library• Automate mobile device and application• Automated UI Acceptance Tests written in

nunit (2.6.x) to be run against iOS and Android• Can be used on Xamarin Apps, iOS (objective-c

/ Swift Apps) and Native Android Apps• XTC does not support WP or Xamarin Forms

WP

Page 4: Xamarin UI Test And Xamarin Test Cloud

Creating a Xamarin.UITest Project Xamarin Studio has 3 Project Templates1. MultiPlatform

Page 5: Xamarin UI Test And Xamarin Test Cloud

Creating a Xamarin.UITest Project

2. IOS Template

Page 6: Xamarin UI Test And Xamarin Test Cloud

Creating a Xamarin.UITest Project

3. Android Template

Page 7: Xamarin UI Test And Xamarin Test Cloud

Most Simple Test• [Test]• public void MyFirstUITest()• {• var app = ConfigureApp• .Android• .ApkFile("MyApkFile.apk")• .StartApp();• • app.EnterText("NameField", ”John Smith");• app.Tap("SubmitButton");• }

Page 8: Xamarin UI Test And Xamarin Test Cloud

UITest Anatomy

• Uses a client / server communication using http and json.

• Http server runs on the device• Communicates with UI Test Client Agent

Page 9: Xamarin UI Test And Xamarin Test Cloud
Page 10: Xamarin UI Test And Xamarin Test Cloud

Android

• Xamarin Test Cloud Agent Server runs in it’s own separate process

• Process is signed with the same keystore as your application so it can drive it with the Android Automation APIs

Page 11: Xamarin UI Test And Xamarin Test Cloud

iOS

• Due to iOS restrictions on iOS the Xamarin Test Cloud Agent has to be shipped with your app in the bundle

• This allows it to access the iOS automation APIs

• Xamarin Test Cloud Agent nuget needs to be installed

Page 12: Xamarin UI Test And Xamarin Test Cloud

Quick Example

app.Tap (c => c.Marked (”New"));

app.EnterText(c => c.Class("UITextField").Index(0), ”John Smith");

app.Tap (c => c.Marked ("Save"));

Page 13: Xamarin UI Test And Xamarin Test Cloud

nUnit

• Test Fixture• 3 A’s (Arrange / Act / Assert)• Categories• Demo – Create Android / IOS Project

Page 14: Xamarin UI Test And Xamarin Test Cloud

UI Test Workflow

• Write automation tests while developing feature

• Write tests, run locally to validate functionality• Create Test run to run in CI / XTC etc.

Page 15: Xamarin UI Test And Xamarin Test Cloud

UI Test Infrastructure

• Tests rely heavily on queries to locate UI elements

• Different techniques to share test logic between platforms

• Your tests can be cross-platform if you write them in similar manner to cross-platform apps.

Page 16: Xamarin UI Test And Xamarin Test Cloud

Setting UI Elements

• Need a way for UI Test to identify UI Elements• UI Test use different UI element ID on Android

and iOS• Can you just text to identify element, but not a

good practice.

Page 17: Xamarin UI Test And Xamarin Test Cloud

Android IDs

• Generally your normal android:id tag is best identifier.

• e.g. android:id="@+id/submitButton"

• This is then used by UI Test• app.Tap (x => x.Id ("submitButton"))

Page 18: Xamarin UI Test And Xamarin Test Cloud

iOS Element IDs

• UI Element Accessibility Identifier • UI Element Accessibility Label• Can set in XCode Identity Inspector or in Code

Page 19: Xamarin UI Test And Xamarin Test Cloud

Identifying UI Elements

• REPL (read, eval, print, loop)• Android - Dump View Hierarchy for UI

Automator• DEMO 1

Page 20: Xamarin UI Test And Xamarin Test Cloud

UI Test Basics

• IApp – different implementations on Android and iOS

• Use ConfigApp fluent builder to create implementation on each platform

• Lots of methods and properties

Page 21: Xamarin UI Test And Xamarin Test Cloud

Xamarin Test Recorder

• A tool for recording automated user interface tests.

• Can be used on Android and iOS• Android runs as standalone app• iOS embeds a plugin into your app bundle to

run (make this is removed on app submission)• Demo 2

Page 22: Xamarin UI Test And Xamarin Test Cloud

Where Can You Run Your Tests

• Locally (devices or emulators / simulators)• CI environments (TeamCity, VSTS, VSMC,

Jenkins, Bitrise etc.)• Xamarin Test Cloud (XTC)

Page 23: Xamarin UI Test And Xamarin Test Cloud

Command Line

• Run locally :-nunit-console.exe in nuget package Nunit.Runners (2.6.4)

• Send to Test Cloud :-• test-cloud.exe

Page 24: Xamarin UI Test And Xamarin Test Cloud

Find Device Ids

• Android :- adb devices• iOS - xcrun instruments -s devices (ios get local

devices) or Xcode• Demo 3

Page 25: Xamarin UI Test And Xamarin Test Cloud

Xamarin Test Cloud

• Test your app on hundreds of actual devices in the Cloud (2000)

• Select Subset of devices to test on• Very detailed analysis of your app• Upload APK, IPA with UI Test Project• iOS IPA are re-signed by Xamarin using their

own provisioning profiles

Page 26: Xamarin UI Test And Xamarin Test Cloud

XTC

• Xamarin resigns your iOS app with their provisioning profile so they can run on their devices.

Page 27: Xamarin UI Test And Xamarin Test Cloud

Some XTC Analysis

• Screenshots• Memory Usage Profiling• CPU Usage• Test logs• Device logs• Demo 4

Page 28: Xamarin UI Test And Xamarin Test Cloud

Thank You

• Any Questions ?