Creating a UI test project using Xamarin Studio

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:

  1. Right-click on the 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.
  2. Next, choose the UI Test App option located within the Xamarin Test Cloud section, under the Multiplatform | Tests section. Ensure that you have selected C# as the programming language to use, as shown in the following screenshot:

    Creating a UI test project using Xamarin Studio

  3. Then, click on the Next button to proceed to the next step in the wizard.
  4. Next, enter TrackMyWalks.UITests to use as the name for your new project as the Project Name field.
  5. Then, ensure that the Create a project directory within the solution directory. has been selected, as shown in the following screenshot:

    Creating a UI test project using Xamarin Studio

  6. Finally, click on the Create button to save your project at the specified location.

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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.27.171