In our previous chapter, we updated our TrackMyWalks
application to allow us to use Facebook to sign into our app. You learned how you can use both the Xamarin.Auth
and Facebook SDK to authenticate if the user is a valid Facebook user. Next, you learned how to create a custom FacebookApiUser
model and FacebookCredentials
class that will be used to store the user's credentials, so that these can be used throughout our app to obtain information about the user, as well as post information to their Facebook wall.
During the development of our TrackMyWalks
app, we have designed and implemented various design patterns and best practices, with the intention of making it easier to maintain and test our app by separating the user interface and business logic.
In this chapter, you'll learn how to create and run unit tests using the NUnit and UITest testing frameworks right within the Xamarin Studio IDE. You'll learn how to write unit tests for our ViewModels that will essentially test the business logic to validate that everything is working correctly, before moving on to testing the user interfaces portion using automated UI testing.
This chapter will cover the following topics:
During the development of our TrackMyWalks
application, we have designed the user interfaces, ViewModels, and ContentPages. As developers, there may be times when we would like to obtain feedback to let us know when our application logic is working as expected. We can use the NUnit testing framework to provide us with that confirmation.
In this section, you'll begin by adding a new solution folder to our existing TrackMyWalks
Portable Class Library solution. This new solution folder will be used to separate each of our NUnit and UITests from our main solution.
The good news is that Xamarin Studio has built in support for the NUnit framework that we can run our unit tests from, and then have our results displayed, right within the Xamarin Studio IDE.
Let's look at how to add a new Solution
folder to our TrackMyWalks
Portable Class Library, by performing the following steps:
TrackMyWalks
solution project and choose the Add | Add Solution Folder menu option, as shown in the following screenshot:
TrackMyWalks.Tests
for the name of the solution folder.Now that you have created the TrackMyWalks.Tests
solution within the main TrackMyWalks
solution project, our next step is to create a new unit test project solution, that will be responsible for testing the business logic within our TrackMyWalksViewModels
.
3.145.39.60