views:

1302

answers:

4

From reasons I won't get into, all our unit tests are using the VSTS test framework. I now want to create an MSBuild script that runs the tests, but I don't want to use mstest.exe from various reasons (it's slower, requires Visual Studio installation everywhere, I need to maintain testrunconfig, etc.)

I've seen that TestDriven.net and TeamCity are able to run VSTS tests 'NUnit style', without using mstest.exe. Are you aware of any standalone command line utility that does this?

A: 

It is possible to run MSTests without installing Visual Studio. See how-do-i-use-mstest-without-visual-studio.

I did this so that I could run my tests as part of my CI process. (I am using CC.NET for my CI solution).


I am in a similar situation as you, in that I want to use TestDriven.NET to get code coverage stats. But, I am running into problems. My first problem is that I am using AssemblyInitialize attributes to initialize a database connection. This isn't supported by NUnit so about half of my tests fail whereas they run fine under MSTest.

So, it seems that translating tests from one test framework to another has pitfalls. If you are aware of that, then go forth, but it might be better to try and keep consistent on one test framework.

quip
Thanks, I'm aware of being able to run mstest.exe outside of VS, but I don't want to use MSTest at all, because of its many issues.
Doron Yaacoby
Okay -- so then can you abandon MSTest completely? Convert all your tests to NUnit? It just seems like having a mixed testing environment is worse than MSTest by itself.
quip
+1  A: 

It seems like TeamCity is simply leveraging Gallio to run VS tests. Gallio appears to have msbuild integration and sounds perfect but after a closer look it seems that it would require a VS install just like MSTest as it appears to depend on MS exes:

The plugin enable condition was not satisfied: '${process:DEVENV.EXE} or 
${process:VSTESTHOST.EXE} or 
${process:QTAGENT.EXE} or 
${process:QTAGENT32.EXE} or 
${process:QTDCAGENT.EXE} or 
${process:QTDCAGENT32.EXE}'.
Host process exited with code: 0

That being said it sounds like at least one person has got it working:

Christoph De Baene - Running MSTest without Visual Studio

John
+5  A: 

You can execute Team System Tests (MSTest) in NUnit if you use a special NUnit Addin that recognizes the MS Test Attributes (TestClass, etc).

Exact Magic Software has an open-source "test-adapter" that can do this.

UPDATE: I've reworked Exact Magic's Msts NUnit Adapter for NUnit 2.5.2.

bryanbcook
Looks like this is what I'm looking for, only it doesn't work with the latest version of NUnit (2.5.2). I've tried the version on which this is supposed to run (2.4.6), but looks like it won't work on my system (Windows 7).
Doron Yaacoby
Often, NUnit addins are tied to the framework under which they were compiled. Has to do with the way NUnit and the addin resolve dependencies. If they provide the source, you should be able to recompile with an updated reference. That's assuming they aren't doing something specific with the 2.4.6 core assemblies, though for the most part the core interfaces haven't changed much. If I find the time, I might give this a go.
bryanbcook
I started looking into it, seems like they have made quite a few breaking changes going into 2.5.2, so it would take some refactoring to get the adapter to work.
Doron Yaacoby
I'm looking at the source, as expected, they're referencing nunit-core.dll, which makes the addin version specific. I've done a bit of nunit addin development, I'll take a poke at this and let you know what I find.
bryanbcook
Awesome! This works great.
Doron Yaacoby
Any chance this will be updated for version 2.5.7?
Vaccano
The 2.5.x stack is largely backward compatible, but it's the references to the nunit-core.dll that fix it to a specific version. I can post a new version (might take a few days before I can get to it) but should be as simple as changing the references and re-compiling. Source is available at that URL.
bryanbcook
A: 

We run VSTS tests using msbuild TestToolsTask on a Cruise Control server. This does not use the MSTEST executable -- the condition you ask for -- but does use a variety of TFS dependencies.

Note that we are migrating tests off of the VSTS test framework for NUnit, mostly because we can create extensions for NUnit to perform useful tasks.

Precipitous