If you have ever taken a look at reviews for mobile apps, you know that users have extremely high expectations. It’s never been more important to create high quality, performant, bug-free apps. When I’m writing mobile apps, I always ensure that I have unit tests to protect myself against regressions and validate that my code works and behaves as expected.
Historically, testing a mobile user interface has been an extremely laborious task that requires manual human interaction to walk through a series of test steps. With multiple mobile operating systems, versions, languages, form factors, and thousands of devices, there are seemingly endless configurations in need of testing.
Xamarin Test Cloud makes testing mobile apps easy. Developers upload their app binary to the cloud and automatically have their app run on thousands of real, physical devices to ensure a mobile app that runs flawlessly on all device configurations. Fragmentation of the Android operating system has been well-documented, but the device landscape for iOS has also grown, now reaching over twenty devices and seven OS versions.
All Xamarin platform subscribers are entitled to 60 minutes of Xamarin Test Cloud per month, which is ideal for running quick tests to confirm a user review for a device you don’t own. The issue has always been how to take the review and turn it into an actionable test, which is where the new Xamarin Test Recorder comes into play.
The Xamarin Test Recorder is a standalone application that allows developers and testers to forgo writing UI test scripts manually. Instead, you can simply interact with your app as you normally would with taps, swipes, and gestures, and the Xamarin Test Recorder records each step. The result is a complete test script without writing a single line of code.
Getting Started
In this example, I’ll create a UITest script using an iOS device, although the process is identical for Android devices. Download the Xamarin Test Recorder. Once installed, you should find the app within the Applications folder on your Mac.
Once I’ve selected the device and app that I wish to test from the dropdown menus, I can start recording my test. To get started, click the “Record” button, which will begin the process of creating a UITest script and record further interactions with the app. Use your app as you normally would by tapping, scrolling, and using gestures and the keyboard. Once you have completed a test, such as validating that you can log into the app, click the “Stop” button to complete the test. You can see how easy it is to create UI tests in this video:
Recording tests is only possible on iOS 8+ or Android 4.3 (API level 18) or higher, but the tests may be played back on older versions of iOS or Android to ensure that your app works flawlessly on all devices.
Running the Test
Now that I have created a test for my UI, I have a few options on what I can do with it. Because the test that is automatically created by the Xamarin Test Recorder is a UITest, I can export the test locally to my favorite IDE (be it Xamarin Studio or Visual Studio) to create a mobile test suite that can be run an unlimited number of times locally on a device or using the iOS or Android simulators. If you wish to opt for a more automated approach, you can also upload the UITest directly to Xamarin Test Cloud and start running it on over 2,000 devices.
If I continue to build UITests for each new feature I add to my app, I can build an extensive test suite to ensure that every future build of the app runs flawlessly on every device, without having to manually test each feature across devices.
Wrapping up
Xamarin Test Recorder provides a fantastic start to creating automated UI tests for your mobile apps. If you’ve never taken advantage of your free Xamarin Test Cloud minutes because of a lack of UITests, then it’s a great time to start! Once you’ve created a set of UITests using the Xamarin Test Recorder, you may want to take things to the next level and start using our REPL for UITest creation for unparalleled control over your tests and an even finer level of control in test scripts.
To get started building automated UI tests and ensure five-star quality for your apps, I recommend watching Xamarin University’s Lightning Lecture on Xamarin Test Recorder, our Xamarin Test Recorder webinar, or reading our documentation.