Search code examples
xamarinxamarin.androidxamarin-studio

xamarin run test individually


I have created an Xamarin Android project and one PCL and one Shared Library. I added some business logic into Shared Library and I would like to test those classes through Xamarin Studio. Those items are not related with UI so I do not need to launch emulator.

enter image description here

Is there any way for me to select & run tests individually?


Solution

  • Taken from my answer on the Xamarin Forums:

    The tests should appear in the Unit Tests pad if you are using NUnit. If I create an NUnit Library project in Xamarin Studio and build the project I can see the tests.

    The screenshot is showing an Android Unit Test library project. The Android Unit Test library is using a special version of NUnit. This project type has to be run with an Android device or simulator. There is no integration into the Xamarin Studio Unit Tests window for this type of project. If you set the Android Unit Test Library project as the startup project you can run the emulator and then run the tests from inside the Android emulator. If you look in the MainActivity file you will see that the code adds the tests from the entire assembly for that project.

    If you want to write tests for code that is not Android specific then create an NUnit library project and then reference your PCL or Shared project. The NUnit Library project will have full integration with the Unit Tests window allowing you to run and debug individual tests.