How to setup AutoFixture.NUnit2
Guidance for getting the AutoFixture.NUnit2 add-in wired up inside NUnit tooling.
With the release of AutoFixture.NUnit2 earlier today, here is some guidance to get it working.
NUnit Documentation: Addin Identification, Loading and Installation
NUnit examines all assemblies in the bin/addins directory, looking for public classes with the
NUnitAddinAttribute
and implementing theIAddin
interface. It loads all those it finds as addins.
After installing the NuGet package you need to copy:
packages\AutoFixture.NUnit2.3.9.0\lib\net40\Ploeh.AutoFixture.NUnit2.Addins.dll
to your local bin\addins
folder.
But where exactly is bin/addins
located? The short answer is wherever your nunit.exe
or nunit-console.exe
resides.
Some default locations:
- NUnit 2.6.2 ->
C:\Program Files (x86)\NUnit 2.6.2\bin\addins
- ReSharper 8 ->
C:\Program Files (x86)\JetBrains\ReSharper\v8.0\Bin\addins
- TestDriven.Net ->
C:\Program Files (x86)\TestDriven.NET 3\NUnit\2.6\addins
Mark Seemann explains how to use AutoDataAttribute
on his blog. Here’s the NUnit example he highlights:
[Test, AutoData]
public void IntroductoryTest(
int expectedNumber, MyClass sut)
{
int result = sut.Echo(expectedNumber);
Assert.Equal(expectedNumber, result);
}
Comments
Share your thoughts and join the discussion below.