Reputation: 5074
How do I use NUnit 3.2? I can't find a tutorial specifically for versions >= 3
, and the other ones I found lead the problems. I've been following this tutorial.
First off, the tutorial says that from VS you can go to Test -> Windows -> Test Explorer
to run your tests. However, this didn't seem to detect any tests I had in my class library project, even after building.
Second, there's no GUI for v3, so that's out of the question.
Third, the tutorial mentions the console version of NUnit. To be clear, I installed NUnit Console Version 3
from NuGet. The tutorial says it's name is nunit-console.exe
, and it's located in the bin
folder of the location you installed NUnit
. Well it appears that v3 and higher don't create a bin
folder, however the nunit-console.exe
doesn't run. Double clicking on it brings up the console for a fraction of a second, then closes it immediately. There's also an nunit-agent.exe
file and an nunit-agent-x86.exe
file, but both of them crash upon running so I assumed I should just leave them alone.
Now I'm stuck. How exactly does one use NUnit 3.2?
Upvotes: 2
Views: 1963
Reputation: 6062
There are various different methods to run NUnit 3 tests...
First off, the tutorial says that from VS you can go to Test -> Windows -> Test Explorer to run your tests.
To make this work, you will need to install the "NUnit3 Test Adapter". Install it through Tools>Extensions and Updates
in Visual Studio. Make sure you get the v3 adapter and not the v2 adapter - they're separate extensions.
Second, there's no GUI for v3, so that's out of the question.
Currently under development! Follow it's progress: here
Third, the tutorial mentions the console version of NUnit.
This is probably the most conventional method. The console can be installed as either a standalone program (Download an installer here), or as a Nuget package. (I'd use the NUnit.Runners
package - it includes some sensible default extensions that NUnit.Console
does not.) This is then installed wherever your packages go (normally the packages
dir in the root of your project?), you can add a reference and Copy Local
if you want to run it in bin
. The console itself is now named nunit3-console.exe
- to run tests, simply pass your test project to that exe on the command line. e.g.
nunit3-console.exe MyTests.dll
Finally, you could also try the NUnitLite
Nuget package. [Docs] This will turn you test project into an executable, so that your tests will run themselves. We found this really helpful for downstream integration.
Given you seem to just be looking for a simple solution to run tests, I'd recommend the NUnitLite package, or the VS adapter.
Upvotes: 4