After installing NUnit from NuGet, how do I force TestDriven.Net to use the NUnit dll referenced by NuGet?
Asked Answered
H

1

9

I am trying to setup a Visual Studio solution that facilitates:

I would like:

  • To keep all references and dependencies under the root of my solution's directory structure

  • The ability to use the,"Test With NUnit",command when I right-click on my project that TestDriven.NET provides.

I do NOT want:

  • To use the version of NUnit that TestDriven.NET installs for itself

I do want:

  • The, "Test With NUnit", command to use the version of NUnit that NuGet installs under my solution's sub directories for me

More detail and what I have already tried:

When you install TestDriven.NET it places its own version of NUnit in a path like:

  • \Program Files (x86)\TestDriven.NET 3\NUnit\2.5

When you use NuGet to install the latest version of NUnit it places NUnit in a path like:

  • Solution_root\packages\NUnit.2.5.10.11092

NuGet automatically adds a reference to \packages\NUnit.2.5.10.11092\lib\nunit.framework.dll for you. That reference is pretty much worthless if you happen to want to easily execute NUnit tests with the TD.Net menu because TD.Net doesn’t actually use the NUnit dll that NuGet just setup for you.

  • How do I force TestDriven.Net's menu to use the referenced NUnit dll in my solution's path instead of the NUnit dll that it installs under \Program Files (x86)\TestDriven.NET 3\NUnit\?

OR

  • If that is not possible, is there an easy shortcut key/menu command to execute the SpecFlow tests with the NUnit that IS under my solution folder without using TestDriven.Net?

Why am I trying to do this?

I installed NUnit with NuGet so that I could keep the testing framework libs inside of my solution and under source control. I need the ability to reference things like nunit.framework.dll under my solution's path (Solution_root\packages\NUnit.2.5.10.11092) and NOT reference it from (\Program Files (x86)\TestDriven.NET 3\NUnit\2.5).

I already tried the suggestions here:

I also do not want to manually copy over and replace the NUnit files installed by TD.Net as that doesn’t allow for solution-specific dependency files and isolation under source control.

Heimer answered 5/5, 2011 at 0:30 Comment(2)
If this is not possible, can anyone recommend an approach to: Install xUnit.net, NUnit, or MSTest via NuGet, have SpecFlow use that package NuGet installed under the solution, and have simple right-click or near automatic way to tell Visual Studio to "run all these tests now"?Heimer
This is not the answer to this exact question but here is the workaround I have been using for now: Right-Click on the class library that contains the specs/tests and choose properties. Choose the Build Events tab. In the Post-build event command line add this: $(SolutionDir)\packages\NUnit.2.5.10.11092\tools\nunit.exe $(TargetPath) /run Replace \NUnit.2.5.10.11092\ with whatever exact version NuGet installed under your sln. Run the post build event: On successful build. After every good build the NUnit GUI will launch and run the tests in the dll.Heimer
V
3

Not sure this is exactly what you're after, but here goes:

Under Visual Studio (i am using 2010):

  1. Go to Tools->Options->Test Driven->Test Runners
  2. This section lists all preconfigured test runners that ship with TD.NET.
  3. Run Regedit.
  4. Go to: *HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\MutantDesign\TestDriven.NET\TestRunners* This will be different under 32bit OS.
  5. Add a new key NUnit 2.5.X (simply copy another key and change whatever settings you need).

  6. Restart Visual Studio.

  7. Under the menu from step #1, you'll find your new test runner.
  8. Click it and Save.

From now on, your tests will run with the test runner you configured.

Vociferation answered 9/7, 2011 at 21:37 Comment(2)
Thank you. I think your method could work pretty well for a specific VS solution (I haven't tried it yet) but it would have to be configured every time for each new VS project (to point the key/path in the registry to the NUnit specific files under the NuGet "packages" directory that is placed under every VS solution). I am looking for a method to automatically wire that up for any/all VS projects.Heimer
The setting in the registry is global per machine. VS reads it from there and lets you select this option.Vociferation

© 2022 - 2024 — McMap. All rights reserved.