C#, MSTest and getting it to work like unittest++

So, I just spent a good bit of this afternoon setting up a C# project that I've been working on to work like UnitTest++.  Let me explain ...

UnitTest++ allows you to add a post-build step that actually runs your code, that's under unit testing after each compilation.  This is really usefull as it allows you to find bugs at compile time (not run-time).

This is considerably harder to do with MSTest (the built in unit test framework in .NET/Dev Studio).  However, your humble servant has gone through the work and figured out the process.

Assume that you have the following:
  1. an assembly, containing your project, called Foo
  2. your Unit Test assembly, called FooTesting
Inside of the Foo project, you will need a post build step that looks like this:
cd $(SolutionDir)
REM Do the following so we don't have a polluted TestResults folder
rmdir /S/Q TestResults
mkdir TestResults
"$(DevEnvDir)mstest.exe"  /testcontainer:$(SolutionDir)FooTesting\bin\$(ConfigurationName)\FooTesting.dll


This took freakin' forever to work out.  However it still doesn't give me the nice formatting of UnitTest++ that allows me to go directly to the line number of the failed test.  It's really a shame there isn't a way for the console spew to be formatted in a way that DevStudio can eat.

Comments

Popular Posts