Let’s take a look to Xamarin’s Test Cloud and examine the basics for implementing automated UI Acceptance Testing for mobile application and explore the main features of this product.
Automating UI tests
At a glance, Xamarin Cloud Test allows you to automate UI Acceptance Testing by just following these steps:
- Setup the UI test-project with UITest in C# or Calabash (Ruby).
- Arrange, Act and Assert your tests.
- Submit and run your tests in the cloud.
1. Setup the UI test-project with UITest in C#
If you already familiar with Unit Testing in .Net, you can easily start your UI tests for your Xamarin Forms and scaffold the project by just indicating the name and location of your test project.
Now, UITest for C# is fully based on NUnit so if you are already familiar with it will be as easily as your normal Unit/Acceptance tests for other projects.
Here is how to add the project step by step with more details.
Target the platforms you need.
By having the project in place, you can just just add the reference and target both Android and iOS from a single cross-platform test suite.
You can take a sample from our repository in GitHub, where you can locate the prototyping app and the code for the UI tests as well.
Making our UITest cross-platform.
Since we are developing a cross-platform app, we can also make our tests to go cross-platform by just refactoring the code to make it run for other platforms as well. So let’s make a class that will abstract the application instance:
public class CrossPlatformTests
By abstracting the application with the IApp member, it will allow you to have shared test suites for both Android and iOS.
2. Arrange, Act and Assert your tests
So by extending the previous class we are able to define the body of test to be run in every platform. Let’s add some basic tests to make sure our app is loaded the first time.
App.Screenshot("Given the app is loaded");
Then our new class can both contain both shared test-cases and add any platform-specific tests if necessary.
3. Submit your tests to the cloud.
Once you have the project in place, you can just start running your test cases right the way.
But before running the test suite in Xamarin Cloud, you need to make sure you’re deploying it in Release mode in Visual/Xamarin Studio to make it work.
Targeting devices to run.
After uploading, you will be prompted to select the number of devices to be run against your test suite that best fill your needs. After run, you can inspect the screenshots that we previously indicated as part of the test cases.
Here are the test results with the snapshots taken in every device:
Here is how you can submit your tests step by step with more details.
Inspecting the results.
There you go! Your tests will start running and you will immediately receive the results as they execute. Additionally, you will receive an email after the tests are done.
Here are the results for the sample app test run with the screenshots taken during the test executions.
And that’s it! Now we can focus on implementing more tests depending on application’s needs.
In further posts we will additional features of Xamarin Test Clould including REPL and deeper assertion cases.
Additional Xamarin resources.
by Esteban Solano