How to enable code coverage without a test list


Aaron pointed out this post by Ben Day that talks about using the RunConfigFile property with a build that runs tests without using test lists (.vsmdi files).  It all boils down to looking like the following (in Orcas, you would specify the $(OutDir) part in the TestContainer’s Include attribute, whereas you don’t in the TFS 2005 power tools TestToolsTask TestContainerInOutput element).

  <ItemGroup>

    <TestContainer Include=”$(OutDir)\HelloWorldTest.dll” />

  </ItemGroup>

  <PropertyGroup>

    <RunConfigFile>$(SolutionRoot)\CSharp\Tests\localtestrun.testrunconfig</RunConfigFile>

  </PropertyGroup>

Read Ben Day’s post, Run tests from your TFS Team Build without a test list (.vsmdi) with code coverage, for the details on setting this up with the TFS 2005 power tools task.

Comments (4)

  1. Aaron Hallberg on Getting The Modified Files For a Team Build In Orcas. Brian Harry on Cool tool for…

  2. I&#39;ve been working a bit with automating our build process and creating a lot of CI builds. Today

  3. Angela Hac says:

    Hello

    It is possible to have the same UnitTest project run against different RunConfig Files?

    Something like this:

    <ItemGroup>  

     <TestContainer Include="$(OutDir)MyUnitTests.dll" />

    </ItemGroup>

    <PropertyGroup>

     <RunConfigFile>$(SolutionRoot)Config01.testrunconfig</RunConfigFile>

    </PropertyGroup>

    <ItemGroup>

     <TestContainer Include="$(OutDir)MyUnitTests.dll" />

    </ItemGroup>

    <PropertyGroup>

     <RunConfigFile>$(SolutionRoot)Config02.testrunconfig</RunConfigFile>

    </PropertyGroup>

  4. Lonny Kruger says:

    Angela,  

    First off, please note that I have not actually tested this to ensure that it works, but it should :).  Please let me know if it doesn't and I will try to investigate further.  That being said, first the bad news. Unfortunately, the .runconfig  applies to the entire test run (invocation of mstest.exe).  In VS2010, I would tell you to add multple runs (one for each runconfigs) to accomplish this.  In 2005, you can simulate this by invoking the TestToolsTask multiple time.  In the TestToolsTask.doc that is included with Buck's powertoy (blogs.msdn.com/…/how-to-run-tests-without-test-metadata-files-and-test-lists-vsmdi-files.aspx) it shows how to "Using the task directly" (talking about the testtoolstask).  You should be able to use this to perform multiple invocations of MSTest in 2005 and 2008.  Please let me know if you run into any problems.