This one came up today and surprised me. I usually use the ReSharper test runner, but I wanted to try out the new, improved Visual Studio Test Explorer in VS2012. I have NUnit-based unit and integration tests and SpecFlow/WatiN UI automation tests that use NUnit behind the scenes.
Visual Studio Extensions and Updates
You’ll need to install the NUnit Test Adapter so the Visual Studio Test Explorer knows what to do. You don’t need to go back and change attributes, references, etc. to use MSTest. It can work with NUnit natively once you add this extension under Tools > Extensions and Updates.
Using SpecFlow with NUnit means you have to set your app.config ApartmentState to STA. This is well documented, but it’s one of those things you have to do to get everything working.
<NUnit> <TestRunner> <add key="ApartmentState" value="STA"/> </TestRunner> </NUnit>
Making this app.config change is all the ReSharper test runner needs, but the Visual Studio Test Explorer needs a little more help. You have to set the NUnit attribute
in your AssemblyInfo.cs for your test project where your SpecFlow tests live.
Now you should be able to run ALL your solution’s tests with the Visual Studio Test Explorer, including the SpecFlow ones!
Visual Studio Test Explorer still needs a lot of work around grouping tests, and Peter Provost says as much in his blog post, but it has come a long way.
About Volare Systems
We build high quality web and mobile apps that run fast and look great on every device . We are based in Denver, Colorado . Let us know if we can help your company with custom software development or custom application development.
We hope this blog post was helpful . If so, please share it using the social toolbar on this page so others can find it. Thank you .