I have Visual Studio 2015. I want to add NUnit's tests for C# project with NuGet Package Manager, and I want to have possibility of running tests with Visual Studio and in Visual Studio.
First I create new C# project: menu File → New → Project → Installed → Templates → Visual C# → Console Application → OK.
Then I install NUnit: menu Tools → NuGet Package Manager → Manage NuGet Packages for Solution... Then I install packages:
In the output I see:
Successfully installed 'NUnit 3.0.0-beta-4' to Tmp.
Successfully installed 'NUnit.Runners 2.6.4' to Tmp.
Successfully installed 'NUnitTestAdapter 2.0.0' to Tmp.
The next step I do is adding new class with code: Right click on project → Add → Class → Visual C# Items → Class name Tests.cs → Add
Then I use below code:
namespace NUnit.Tests
{
using System;
using NUnit.Framework;
[TestFixture]
public class Tests
{
[Test]
public void t1()
{
}
[Test]
public void t2()
{
}
}
}
And finally when I press RunAll on Test Explorer I see:
------ Discover test started ------
NUnit VS Adapter 2.0.0.0 discovering tests is started
Attempt to load assembly with unsupported test framework in C:\Users\Grzegorz\Desktop\Tmp\Tmp\bin\Debug\Tmp.exe
NUnit VS Adapter 2.0.0.0 discovering test is finished
========== Discover test finished: 0 found (0:00:00,0720041) ==========
No tests are being discovered.
The strange thing is that I found no tutorial when anybody uses NuGet to install NUnit in Visual Studio 2015 and run tests in Visual Studio.
Navigate to Tools -> NuGet Package Manager -> Manager NuGet Packages for Solution. Search for NUnit & NUnit Test Adapter in the Browse tab. Click on Install and press OK to confirm the installation. With this installation, the NUnit framework can be used with C#.
By default the NUnit installation program places all of the files into the C:\Program Files\NUnit 2.4 directory. In the installation directory there are three sub-directories: bin, doc, and samples. Source code is no longer provided with the binary installation package.
It looks like you are using NUnit 3 beta. From the error message I'd guess the test runner doesn't support it. Try changing the NUnit package to a 2.x version and see if that makes a difference.
I had the same issue, and my colleague solved it by installing:
NUnit3 Test Adapter
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With