Поделиться через


How to generate multiple .trx (test results) files and publish them with custom names while using Team Build 2008

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="&quot;$(ProgramFiles)\Microsoft Visual Studio 9.0\Common7\IDE\mstest&quot; /testcontainer:&quot;$(OutDir)\TestProjOne.dll&quot; /resultsfile:&quot;C:\builds\$(TeamProject)\$(BuildDefinition)\TestResults\one.trx&quot; /publish:&quot;$(TeamFoundationServerUrl)&quot; /publishbuild:&quot;$(BuildNumber)&quot; /teamproject:&quot;$(TeamProject)&quot; /platform:&quot;Any CPU&quot; /flavor:&quot;Release&quot; /runconfig:&quot;c:\builds\$(TeamProject)\$(BuildDefinition)\Sources\UnitTests\one.testrunconfig&quot;"></Exec>

<

Exec Command="&quot;$(ProgramFiles)\Microsoft Visual Studio 9.0\Common7\IDE\mstest&quot; /testcontainer:&quot;$(OutDir)\TestProjTwo.dll&quot; /resultsfile:&quot;C:\builds\$(TeamProject)\$(BuildDefinition)\TestResults\two.trx&quot; /publish:&quot;$(TeamFoundationServerUrl)&quot; /publishbuild:&quot;$(BuildNumber)&quot; /teamproject:&quot;$(TeamProject)&quot; /platform:&quot;Any CPU&quot; /flavor:&quot;Release&quot; /runconfig:&quot;c:\builds\$(TeamProject)\$(BuildDefinition)\Sources\UnitTests\two.testrunconfig&quot;"></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>

Customizable Team Foundation Build Targets

MSTest.exe Command-Line Options