views:

52

answers:

3

Is there a way to create unit tests that can be run with the Visual Studio Unit Testing Framework as well as NUnit? I personally prefer the Visual Studio one, but the build server I am using only does NUnit, so I would like to support both if possible.

EDIT: To clarify, I would like to run my own tests using Visual Studio (without add-ons or extensions), but other collegues would like to use NUnit, and the build server needs NUnit. I cannot change anything except the code, so I thought there would be an easy way to satisfy everyone, but its looking to be a bit of a challenge :)

+1  A: 

Here is one way to do that using precompiler directives and aliases via the "using" keyword

RyanHennig
@RyanHennig: I have already used that method. It requires a separate binary for either NUnit or VS unit testing (the precompiler directives are interpreted when the code in being compiled, not when it is being executed).
Nippysaurus
+2  A: 

Sounds like you need a Visual Studio test runner. If you install Gallio, it will use VS test runner to run any kind of unit tests(xUnit, nUnit, MBUnit). Also Resharper and CodeRush have their own test runners.

Igor Zevaka
A: 

JustCode has a unit test runner that can run tests written using xUnit, NUnit, MbUnit, or Visual Studio Unit Testing Framework. You can see it in action here

Joshua
He said build server, though - I expect he means automated from a command-line whereas that page says "inside Visual Studio"
Rup