1.Inside your TFSBuil.Proj file overwrite the BeforeTestConfiguration target with something similar to the one below.
2. Specify the name of the test results files on 2 locations.
- Inside the command line below – this will be the actual name of the file
- Inside the *.testrunconfig file – this will be the test run name displayed on the build report
3. (Optional) Copy the test results files from the build folder to the drop folder.
<
Target Name="BeforeTestConfiguration">
<
Exec Command=""$(ProgramFiles)\Microsoft Visual Studio 9.0\Common7\IDE\mstest" /testcontainer:"$(OutDir)\TestProjOne.dll" /resultsfile:"C:\builds\$(TeamProject)\$(BuildDefinition)\TestResults\one.trx" /publish:"$(TeamFoundationServerUrl)" /publishbuild:"$(BuildNumber)" /teamproject:"$(TeamProject)" /platform:"Any CPU" /flavor:"Release" /runconfig:"c:\builds\$(TeamProject)\$(BuildDefinition)\Sources\UnitTests\one.testrunconfig""></Exec>
<
Exec Command=""$(ProgramFiles)\Microsoft Visual Studio 9.0\Common7\IDE\mstest" /testcontainer:"$(OutDir)\TestProjTwo.dll" /resultsfile:"C:\builds\$(TeamProject)\$(BuildDefinition)\TestResults\two.trx" /publish:"$(TeamFoundationServerUrl)" /publishbuild:"$(BuildNumber)" /teamproject:"$(TeamProject)" /platform:"Any CPU" /flavor:"Release" /runconfig:"c:\builds\$(TeamProject)\$(BuildDefinition)\Sources\UnitTests\two.testrunconfig""></Exec>
<
Copy SourceFiles="c:\builds\$(TeamProject)\$(BuildDefinition)\TestResults\one.trx" DestinationFolder="c:\drop\$(BuildDefenition)\$(BuildNumber)\TestResults\" />
<
Copy SourceFiles="c:\builds\$(TeamProject)\$(BuildDefinition)\TestResults\two.trx" DestinationFolder="c:\drop\$(BuildDefenition)\$(BuildNumber)\TestResults\" />
</
Target>
Sample One.testrunconfig file
<?xml version="1.0" encoding="UTF-8" ?>
- <TestRunConfiguration name="One" id="1b201214-520e-452b-8553-385566f0c402" xmlns="microsoft.com/schemas/VisualStudio/TeamTest/2006">
<Description>This is a default test run configuration for a local test run. </Description>
<NamingScheme baseName="One" appendTimeStamp="false" useDefault="false" />
- <TestTypeSpecific>
- <WebTestRunConfiguration testTypeId="4e7599fa-5ecb-43e9-a887-cd63cf72d207">
- <Browser name="Internet Explorer 7.0">
- <Headers>
<Header name="User-Agent" value="Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1) " />
<Header name="Accept" value=" */* " />
<Header name="Accept-Language" value=" {{$IEAcceptLanguage}} " />
<Header name="Accept-Encoding" value="GZIP" />
</Headers>
</Browser>
<Network Name="LAN" BandwidthInKbps="0" />
</WebTestRunConfiguration>
</TestTypeSpecific>
</TestRunConfiguration>