Writing UI tests

Xamarin.UITest.Helpers is a suite of enhancements for Xamarin.UITest that makes tests easier to read and write; and creates better reports in Xamarin Test Cloud.

Getting started

1. Add Helpers to your projects

Add Xamarin.UITest.Helpers on NuGet to your test and app projects.

2. In your test fixture, import Helpers with using static

using Xamarin.UITest;
using static Xamarin.UITest.Helpers;

3. In your fixture setup, set Helpers.App to your IApp instance

[SetUp]
public void BeforeEachTest()
{
  App = AppInitializer.StartApp(platform);
}

4. Write a login test

This test will pass if:

  1. Your first screen has username and password entries, and a "Login" button.
  2. After login, your app proceeds to a screen with a label containing the text "logged in."
[Test]
public void TestLogin()
{
  Entry.WithPlaceholder("Username").EnterText("David");
  Entry.WithPlaceholder("Password").EnterText("s3cr3t");
  Button.Marked("Login").Tap();

  Label.WithText("logged in").WaitUntilExists();
}

(Here's a sample app that passes this test.)