Learnt something new with MsTest today… in the scripts I have for our projects we run the tests using MsTest from the command line as follows:
<Exec Command='"$(VS80COMNTOOLS)..\IDE\mstest.exe" /testcontainer:Acme\Group\BizTalk\Utilities\Tests\bin\$(ConfigurationName)\Acme.Group.BizTalk.Utilities.Tests.dll /runconfig:localtestrun.testrunconfig' />
<Exec Command='"$(VS80COMNTOOLS)..\IDE\mstest.exe" /testcontainer:Acme\Group\BizTalk\PipelineComponents\Tests\bin\$(ConfigurationName)\Acme.Group.BizTalk.PipelineComponents.Tests.dll /runconfig:localtestrun.testrunconfig' />
<Exec Command='"$(VS80COMNTOOLS)..\IDE\mstest.exe" /testcontainer:Acme\Group\BizTalk\Build\Tests\bin\$(ConfigurationName)\Acme.Group.BizTalk.Build.Tests.dll /runconfig:localtestrun.testrunconfig' />
<Exec Command='"$(VS80COMNTOOLS)..\IDE\mstest.exe" /testcontainer:Acme\Group\BizTalk\Testing\Tests\bin\$(ConfigurationName)\Acme.Group.BizTalk.Testing.Tests.dll /runconfig:localtestrun.testrunconfig' />
This will run out 4 test assemblies fine. Ok so now I was interested in the code coverage aspect and getting the report into CruiseControl (more on this later) and I found a couple of things.
1. Each assembly is run completely seperately in different folders when it is tested
2. There are 4 coverage reports, 1 for each assembly
This is really what you would expect, but in order to run the tests and get just one coverage file I needed to change the way I was calling MsTest. Basically thanks to my collegue Callum Hibbert (who I always ask if I have a problem with anything Build or TFS related) I found that when calling MsTest you can specify multiple test containers an example of which would be as follows:
<Exec Command='"$(VS80COMNTOOLS)..\IDE\mstest.exe" /testcontainer:Acme\Group\BizTalk\Utilities\Tests\bin\$(ConfigurationName)\Acme.Group.BizTalk.Utilities.Tests.dll /testcontainer:Acme\Group\BizTalk\PipelineComponents\Tests\bin\$(ConfigurationName)\Acme.Group.BizTalk.PipelineComponents.Tests.dll /runconfig:localtestrun.testrunconfig' />
(ive only specified 2 here to keep the example simpler but you can supply 4 in the same way)
This means when I now run the reports I have 1 folder containing all of the test stuff and also 1 test coverage file.
[As a side note on this we done have Team Suite or Team Test to use a test list]