I'm using Visual Studio 2017 to develop Xamarin Android application. I want to add simple unit tests of logic only. For that purpose, I tried adding "Unit Test App (Android)" or "Class Library (Android)" projects with unit tests and none of them work.
Unit Test App (Android)
I add new project to my solution of type "Unit Test App (Android)". Generated project contains TestsSample
class with sample tests, but I have no idea how to launch them. I have ReSharper installed, but when right clicking on the project/class I don't have option to run the tests.
When I go to "Test" -> "Run" -> "All tests", the solution is built, but nothing more happens.
Class Library (Android) with nUnit
The other trial was to add new project of type "Class Library (Android)" to the solution. After, I installed nUnit nuget package (install-package nunit
which installed package 'nunit.3.6.1' with respect to project 'MoneyBack.Tests', targeting 'MonoAndroid,Version=v6.0'), installation was successful.
I added the following class:
using NUnit.Framework;
namespace MoneyBack.Tests
{
[TestFixture]
public class Class1
{
[Test]
public void SampleTest()
{
Assert.IsTrue(true);
}
}
}
Now when right-clicking on the tests project I see ReSharper's option "Run Unit Tests", so I clicked it and got the following exception:
Am I doing something wrong ? Or it's the issue with VS2017 ? I don't know if I should install VS2015 back or there is some solution. Thanks for your help!
Unit Test App (Android)
project needs to be run on a device/emulator as it requires theXamarin.Android
framework to run. AlsoNUnit 2.6.x
is required. - SushiHangoverUnit Test App (Android) project
, set an Android device/emulator target and build/run the application (Resharper does not know anything about Xamarin-specfic device testing). - SushiHangover