views:

19

answers:

2

We have a Visual Studio 2008 solution with a large number of projects in it. For the current product, only some of those projects are being used.

We've created a build configuration for that product so we don't have to build every project in the solution.

I want to be able to easily run all the unit tests that are relevant for this build. There are a large number of tests for projects we don't care about at this point. Because those projects aren't in the build, they won't be compiled and therefore we can't test them.

Is there an easier way to define which tests should be run rather than just picking and choosing them from the Test View?

+1  A: 

You could create some msbuild scripts which will only compile specific projects, and you can have a script for each scenario.

eg.

for 2 C# projects A and B, with 2 tests AT and BT:

<if condition="$(BuildA)"> <!-- If Building Project A -->
<csc ... "A" /> <!-- Build A project -->
</if>

<if condition="$(BuildA)"> <!-- If Building Project A -->
<csc ... "AT" /> <!-- Build AT project -->
<exec "AT" ... /> <!-- Run AT tests -->
</if>

Then run the tests that have been built.

Russell
+1  A: 

Using the *.csproj file, open it in a text editor and add in your own MSBuild task to run the unit tests in an AfterBuild target. Something like:

<Target Name="AfterBuild">
   <Exec Command="mstest.exe /detail:errormessage /detail:errorstacktrace /runconfig:$(TestRunConfig) /testcontainer:[relative path to your test assembly DLL] /resultsfile:UnitTestResults.trx" />
</Target>
andrew