Question

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 :)

Was it helpful?

Solution

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.

OTHER TIPS

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

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

You can write framework agnostic asserts using a library called Should. It also has a very nice fluent syntax which can be used if you like fluent interfaces. I had a blog post related to the same.

http://nileshgule.blogspot.com/2010/11/use-should-assertion-library-to-write.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top