NUnit tests in a separate project, same solution

nunit, visual-studio, visual-studio-2008

Solution

Instead of setting up NUnit as an External Tool, I set the unit test project as the StartUp project. In the project's Properties screen, set the Start Action to "Start external program" and point it to `nunit.exe`. In the Start Options section, I specify the test assembly (no path necessary) in the "Command line arguments" box. At this point, simply press F5 to start up NUnit.

Problem

I have a solution containing my main project and a test project using NUnit. Everything compiles but when I run NUnit I get the exception below after the tests load, and the tests fail. I've added the main project as a reference, and I have $(ProjectDir)bin/Debug/$(TargetName)$(TargetExt) in the arguments for NUnit in the external tools setup, with a blank initial directory. ``` MyMainProjectTests.Database.TestAddDelete: System.BadImageFormatException : Could not load file or assembly 'MyMainProject, Version=1.1.1.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format. TearDown : System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation. ----> System.BadImageFormatException : Could not load file or assembly 'ChickenPing, Version=1.1.1.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format. ``` After scouring for hours the only thing I've found is a bug in VS2005 which mentions the /bin and /obj directories, but the answer provided didn't help. Any solutions?

Original source