Allgemein Für Administratoren Für Architekten Für Entwickler Für Projektleiter Für Tester News Produkte Publikationen
X
Lars Roith
Lars Roith ist Senior Software Consultant und Geschäftsführer der AIT. Eines seiner „Steckenpferde“ ist die Architektur- und Prozessberatung. Lars Roith ist maßgeblich beteiligt am hauseigenen Softwareentwicklungsprozess (AIT SEP) und ist für das AIT Task Board verantwortlich.

Lars Roith

Prevent test results blowing up your TFS Databases

Montag, 14. Juni 2010

After migrating from TFS 2008 to TFS 2010 the way test results are handled has changed.

Szenario

When running tests a whole system szenario is setup which means that a lot of files and additional content  is copied to the test run folder

Issue

 When test results are published to TFS 2010 the content of the test run folder is also published. This causes the TFS databases to grow rapidly

Solution

1.       Disable publishing test result

2.       Cleanup test result folders before publishing the test results

3.       Publish test results manually

HowTo: Disable publishing test results

Simply set a specific MSBuild property that is used by the TestToolsTask

<PublishTestResults>false</PublishTestResults>

TFS 2010: Cleanup test result folders before publishing the test results

The test run’s execution folder is the out directory. From that directory we drop everything except the  instrumented binaries and debug symbols. This allows us to still retrieve code coverage data. Dropping all other files will prevent the test execution when we open the test results from the build summary.

<CreateItem Include="$(TestResultsRoot)\**\Out\*.instr.pdb">

    <Output TaskParameter="Include" ItemName="InstrumentedDebugSymbolFiles"/>

</CreateItem>

<RegExReplace Input="@(InstrumentedDebugSymbolFiles)" Expression="\.instr\.pdb$" Replacement=".exe">

    <Output ItemName="InstrumentedExeAssemblies" TaskParameter="Output" />

</RegExReplace>

<RegExReplace Input="@(InstrumentedDebugSymbolFiles)" Expression="\.instr\.pdb$" Replacement=".dll">

    <Output ItemName="InstrumentedDllAssemblies" TaskParameter="Output" />

</RegExReplace>

<CreateItem Include="$(TestResultsRoot)\**\Out\**\*" exclude="@(InstrumentedExeAssemblies);@(InstrumentedDllAssemblies);@(InstrumentedDebugSymbolFiles)">

 

    <Output TaskParameter="Include" ItemName="TestOutputToDelete"/>

</CreateItem>

<Delete Files="@(TestOutputToDelete)"  />

HowTo: Publish test results manually

In order to publish the test result we just use the publishing feature of mstest. We identify all trx files and publish them one by one. For ease of use we do not determine the MSTest.exe path dynamically. We just defined a property that keeps the path.

<MSTestCommand>$(ProgramFiles)\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe</MSTestCommand>

Using this property and the information from the current build we can easily publish the results as follows:

<!– Get all trx files for publishing –>

<CreateItem Include="$(TestResultsRoot)\**\*.trx">

    <Output TaskParameter="Include" ItemName="TestResultFiles"/>

</CreateItem>

   

<!– Now publish all trx files –>

<Exec Command="&quot;$(MSTestCommand)&quot; /publish:&quot;$(TeamFoundationServerUrl)&quot; /publishbuild:&quot;$(BuildUri)&quot; /PublishResultsFile:&quot;%(TestResultFiles.Identity)&quot; /teamproject:&quot;$(TeamProject)&quot; /platform:&quot;Mixed Platforms&quot; /flavor:&quot;Debug&quot;" ContinueOnError="true" />

Please also notice that we do not determine the build configuration (platform and flavor) dynamically. We “hard-coded” it.

Verwandte Artikel:

Benötigen Sie Unterstützung bei der Software-Entwicklung und Architektur von .NET basierten Lösungen oder bei Einführung und Anpassung von Visual Studio / Microsoft Test Manager / Team Foundation Server?

Wir stehen Ihnen unter info(at)aitgmbh.de gerne zur Verfügung.

Hinterlasse eine Antwort