2. Overview
• Xamarin UI Test
• How and where Xamarin UI Tests can be run
• Xamarin Test Cloud
3. 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
7. Most Simple Test
• [Test]
• public void MyFirstUITest()
• {
• var app = ConfigureApp
• .Android
• .ApkFile("MyApkFile.apk")
• .StartApp();
•
• app.EnterText("NameField", ”John Smith");
• app.Tap("SubmitButton");
• }
8. UITest Anatomy
• Uses a client / server communication using
http and json.
• Http server runs on the device
• Communicates with UI Test Client Agent
9.
10. 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
11. 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
14. 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.
15. 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.
16. 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.
17. 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"))
18. iOS Element IDs
• UI Element Accessibility Identifier
• UI Element Accessibility Label
• Can set in XCode Identity Inspector or in Code
20. 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
21. 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
22. Where Can You Run Your Tests
• Locally (devices or emulators / simulators)
• CI environments (TeamCity, VSTS, VSMC,
Jenkins, Bitrise etc.)
• Xamarin Test Cloud (XTC)
23. Command Line
• Run locally :-
nunit-console.exe in nuget package Nunit.Runners (2.6.4)
• Send to Test Cloud :-
• test-cloud.exe
24. Find Device Ids
• Android :- adb devices
• iOS - xcrun instruments -s devices (ios get local
devices) or Xcode
• Demo 3
25. 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
26. XTC
• Xamarin resigns your iOS app with their
provisioning profile so they can run on their
devices.
27. Some XTC Analysis
• Screenshots
• Memory Usage Profiling
• CPU Usage
• Test logs
• Device logs
• Demo 4