Migrating Solutions for Test Cloud Integration Overview

Transcription

Migrating Solutions for Test Cloud Integration Overview
Migrating Solutions for Test Cloud Integration
Overview
Starting with Xamarin Studio 5.9 and Xamarin for Visual Studio 3.11, Xamarin enhanced support for Test Cloud
in each IDE:
Updated Templates – New templates for mobile solutions that include a UITest project.
Run Test in Test Cloud – It is now possible to run UITests in Test Cloud using Xamarin Studio or Visual
Studio.
This guide will cover how to upgrade older projects that were created before the Test Cloud integration features
were added to Xamarin Studio or Xamarin for Visual Studio.
The general process for migrating older UITest projects is as follows:
1. Upgrade to Xamarin Studio 5.9 or Xamarin for Visual Studio 3.11
2. Update the UITest Nuget package – IDE integration is provided in version 0.7.2 or higher of the NuGet
package.
3. Point the UITest project to the application projects – In order for the IDE to run the UITests for you, it
needs to know about the mobile projects in the solution file. How to do this is covered in the following
section.
4. Remove any explict UITest calls that load the APK / IPA – (optional) Your old tests may have code with
the location of the APK or IPA hard coded. Once UITest project points to the test project, the IDE will set
the path to the application bundle for you.
Requirements
If you have created your solution using Xamarin Studio 5.9 or Xamarin for Visual Studio 3.11 or higher, your
solution automatically has a UITest project that is configured to take advantage of running tests in the IDE.
Pointing the UITest Project to the Mobile Projects
The most significant change is to update the UITest project to point to the mobile projects. This will allow UITest
to automatically determine the path to the application bundle for you, eliminating some of the boilerplate
initialization code present in UITests.
1. Open the Unit Tests pad, View > Pads > Unit Tests.
2. Expand the Tree View and expose the Test Apps node:
3. Right click on Test Apps, and select Add App Project:
4. From the dialog that appears, point the UITest project to the mobile applications that Xamarin Studio
should run tests for:
To upgrade your UITest project in Visual Studio, select the UITest project and select Project > Add References....
From the Reference Manager dialog that appears, select the mobile projects:
Configuring IApp
The Submitting UITests to Xamarin Test Cloud and Testing on Devices both describe how the IDE will execute
tests on the appropriate target. It is no longer necessary to specify the path to the APK or APP/IPA. This means
that existing calls to ConfigureApp can be simplified to one of the following:
ConfigureApp.Android.StartApp()
ConfigureApp.iOS.StartApp()
If you have a solution that targets both Xamarin.iOS and Xamarin.Android, the following helper class can be used
to initialize an IApp instance that is appropriate for the platform being tested:
public class AppInitializer
{
public static IApp StartApp(Platform platform)
{
if(platform == Platform.Android)
{
return ConfigureApp.Android.StartApp();
}
return ConfigureApp.iOS.StartApp();
}
}
Then, update each test class to specify the platform as a part of the TestFixture attribute:
[TestFixture(Platform.Android)]
[TestFixture(Platform.iOS)]
public class Tests
{
IApp app;
Platform platform;
public Tests(Platform platform)
{
this.platform = platform;
}
[SetUp]
public void BeforeEachTest()
{
app = AppInitializer.StartApp(platform);
}
[Test]
public void ClickingButtonTwiceShouldChangeItsLabel()
{
// Test code omitted
}
}
Summary
This guide discussed how to migrate old UITest projects to take advantage of the IDE integration provided by
Xamarin Studio 5.9 and newer. This guide discussed how to migrate old UITest projects to take advantage of the
IDE integration provided by Visual Studio 3.11 and newer.