Xamarin.UITests Quick Starts

PDF for offline use:
Related Articles:

Let us know how you feel about this.


0/250
Thanks for the feedback!

last updated: 2016-10

This section contains several quickstarts to help you get started with UITest. Each quickstart focuses on how to create test for simple application on a single platform.

Overview

These quick starts will take you through writing some automated tests using Xamarin.UITest for a sample application. The user can enter a credit card number, and the application will validate the credit card number according to this one rule:

  • The credit card number must be exactly 16 characters long.

If the user enters a credit card message that is too long or too short, then the application will display an error message with that information.

This application has a fairly simple workflow, so we will be able to keep all of the UITests in a single test fixture. This one test fixture will have four tests in it:

  • No Credit Card Number – The application should display an error message that the value isn't a credit card number.
  • A 15-digit Credit Card Number – The application should display an error message that the credit card number is too short.
  • A 16-digit Credit Card Number – The application should display a new screen with a message that the credit card number is valid.
  • A 17-digit Credit Card Number – The application should display an error message that the credit card number is too long.

The following screenshots show the application in action on Android and iOS, respectively:

To keep things simple, the quick starts will only focus on a single platform at at time, and we'll only write one UITest. Each platform is covered in its own section.

In these quick starts we will cover the following:

  • Exploring the UI with the REPL – UITest provides an interactive shell, known as a REPL (read-eval-print-loop) that can be used to explore the user interface.
  • Using the UITest API – We shall see some of the UITest API's that are used to interact with the user interface.
  • Running the Tests – First we will run the tests locally as they are being developed, then we will upload them to Xamarin Test Cloud.

Requirements

In order to run Xamarin.UITests with Xamarin Studio, the following dependencies must be met:
  • NUnit 2.6.x – Xamarin.UITest is not compatible with NUnit 3.x.
  • Android SDK – Only if testing Android apps.
  • Java Developers Kit – Only if testing Android apps.
  • Xcode Command Line Tools – Only for testing iOS apps.

Xamarin.UITest does not support Windows Phone.

In order to run Xamarin.UITests with Visual Studio, the following dependencies must be met:
  • NUnit 2.6.x – Xamarin.UITest is not compatible with NUnit 3.x.
  • A Test Runner for Visual Studio – A 3rd party test runner, such as the NUnit Test Adapter or Resharper from Jetbrains, is required for Visual Studio to be able to run the NUnit tests.
  • Android SDK – Only if testing Android apps. Windows requires that the ANDROID_HOME environment variable is set with the path to the Android SDK.
  • Java Developers Kit – Only if testing Android apps.

It is not possible to run UITests for iOS apps in Visual Studio or on Windows.

Xamarin.UITest does not support Windows Phone.

You must already have an account with Xamarin Test Cloud and be familiar with the Introduction to Xamarin Test Cloud guide. You must also have setup a Test Cloud team, as described in the Organizations & Teams

Xamarin Workbook

If it's not already installed, install the Xamarin Workbooks app first. The workbook file should download automatically, but if it doesn't, just click to start the workbook download manually.