- How to sign up for a Xamarin Test Cloud account
- Create a coded UI test
- Run tests in the cloud
- Record an UI test by using Xamarin Test Recorder
- Open Xamarin Website
- Choose Products > Xamarin Test Cloud
- Click on "Start your free trial"
- Register
-
Open Visual Studio
-
Open the Hanselman.Forms solution
-
Rename
Class1.cs
toTests.cs
-
Add NuGet packages
Important: choose the specified versions: Xamarin.UITest requires NUnit 2.6.3 or higher. Xamarin.UITest is not compatible with NUnit 3.0.Install-Package NUnit -Version 2.6.4
Install-Package NUnitTestAdapter -Version 2.0.0
Install-Package Xamarin.UITest -Version 1.3.8
[TestFixture]
public class Tests
{
private IApp app;
[SetUp]
public void BeforeEachTest()
{
app = ConfigureApp
.Android
.StartApp();
}
[Test]
public void AppLaunches()
{
app.Screenshot("First screen.");
}
}
Detailed functionality can be found at Xamarin.UITest.IApp, e.g.
- Back
- Tap / DoubleTap
- EnterText
- PressEnter
- PinchToZoomIn
- SetOrientationLandscape / SetOrientationPortrait
- SwipeLeft / SwipeRight
- Screenshot
[Test]
public void ClickThroughTest()
{
this.TestMenuItem("About");
this.TestMenuItem("Blog");
this.TestMenuItem("Twitter");
this.TestMenuItem("Hanselminutes");
this.TestMenuItem("Ratchet");
this.TestMenuItem("Developers Life");
}
private void TestMenuItem(string name)
{
app.WaitForElement(x => x.Marked("OK"));
app.Tap(x => x.Marked("OK"));
app.WaitForElement(x => x.Marked(name));
app.Tap(x => x.Text(name));
app.Screenshot(name);
}
- Make a release build of the app
- Create an .apk file
- Publish to Xamarin Test Cloud
- Select target devices for the test (Note: Using the trial edition restricts the amount of parallel tested devices to 3.)
Important: This feature is only available in Visual Studio Enterprise edition. Explain the idea or show the following steps live.
- Install the Xamarin Test Recorder through Visual Studio > Tools > Extensions and Updates
- Open the properties of your Hanselman.Android project and disable Use Shared Runtime
- Open the Tests.cs class from your UI test project
- Click on the Test Recorder icon and select Record new test > Build Hanselman.Android project
- The app is started in the emulator, wait until it is loaded completely.
- Click through several pages in the app, you will see the recorded actions live in Visual Studio
- Go to Visual Studio to stop the current test case.