In the previous section, we saw how easy it is to create a set of unit tests that enable us to test our ViewModels
within the TrackMyWalks
project. Whilst unit testing ensures that a significant amount of code is tested, it is primarily focused on testing the actual business logic within the app. This leaves the user interface portions of the app still untested, but the beauty of using UI testing allows us to automate specific actions within our app's user interface to ensure that it is working as expected.
Fortunately, Xamarin Studio provides you with a rich set of tools for performing automated UI tests, and these can be both written in C# and make use of the UITest framework. Let's start by creating a new UITest project within our TrackMyWalks.Tests
project solution, by performing the following steps:
TrackMyWalks.Tests
solution project and choose the Add | Add New Project... menu option. If you can't remember how to do this, you can refer to the section entitled Creating a unit test project using Xamarin Studio, located within this chapter.
TrackMyWalks.UITests
to use as the name for your new project as the Project Name field.
Once your project has been created, you will be presented with the Xamarin Studio development environment, with your new project created within the TrackMyWalks.Tests
solution folder.
You will notice that by default our project has created a file named Test.cs
that we can use to write our UITests, as well as a class named AppInitializer.cs
that is essentially used by the Test.cs
class to create an IApp
instance and start the app for each test condition. Since we will only be creating one UITest for this chapter, we can essentially just use the Test.cs
file for now.
In an ideal world, you would be creating various tests, one for each test condition, so it would make sense to break each of your UITests into individual files. In the next section, we will learn about some of the commonly used UITest methods that we can use while performing UITests for our application's user interface.
3.147.27.171