James Montemagno
James Montemagno

Live, Love, Bike, and Code.

Live, Love, Bike, and Code

Share


Tags


Setting Up Visual Studio to run Xamarin.UITests

As of recent I have been on a quest to always stay in Visual Studio. It has always been my favorite IDE and now that the iOS Simulator is on Windows and our Mac Build Host is rock solid it is time for me to shove that macOS machine in the closet :) I recently aquired a brand new Surface Book and got it all setup for Xamarin development, but what about testing? It has been some time since I got all of my NUnit and Xamarin.UITests running in Visual Studio and I thought it would be nice to run down what is necessary to get setup.

Test Explorer

It should already be built into Visual Studio, but you need to find how to actually show the test explorer, which of course isn’t under your typical View menu, but instead the Test menu:

NUnit Test Adapter

Now the problem here will be that if you are writting NUnit or UITests nothing will show up. This is because the Test Explorer only seeks out MSTests. Do not fear as you can head up to Tools->Extensions and Updates and then search for NUnit and you will see the Test Adapters. There is one for NUnit 2 and one for NUnit 3, we should install NUnit 2 since that is what UITest is currently based off of.

Now all of our NUnit tests will show up when we open a project with either unit tests or UITests:

Xamarin.UITest Recorder

We of course can create NUnit tests, but the fun is testing our user interface for iOS and Android. With the new preview of the Test Recorder for Visual Studio you now never have to leave VS, which is pretty great! This is also in the Extensions gallery:

Now we will see a test recorder icon and thing are ready to go!

Here is a short video:

Of course, this is only for Android currently so if you need to run a UITest on iOS simply head over to the mac and checkout the test recorder on macOS!

Copyright © James Montemagno 2016 All rights reserved. Privacy Policy

View Comments