How to prevent publishing test results with team build.

by Donovan Brown 14. July 2009 11:25

Problem:

I do not want to publish the test results with my team build.

Solution:

Override CoreTestConfiguration target and adjust the parameters for the call the TestToolsTask.

Code:

<Target Name="CoreTestConfiguration"
       
DependsOnTargets="$(CoreTestConfigurationDependsOn)"
                Outputs="@(TestOutputs)">

<Warning Condition=" '$(V8TestToolsTask)'=='true' and '$(TestNames)'!='' "
         Text
="Warning: The TestNames property cannot be used in in combination with the V8 TestToolsTask and will be ignored." />

<Warning Condition=" '$(V8TestToolsTask)'=='true' and '@(LocalTestContainer)' != '' "
         Text
="Warning: The TestContainer item group cannot be used in combination with the V8 TestToolsTask and will be ignored." />

<PropertyGroup>
  <
ContinueOnTestError Condition=" '$(StopOnTestFailure)' != 'true' ">true</ContinueOnTestError>
  <
ContinueOnTestError Condition=" '$(StopOnTestFailure)' == 'true' ">false</ContinueOnTestError>
</
PropertyGroup>

<!-- MetaDataFile tests for non-desktop builds. -->
<
TestToolsTask
   Condition=" '$(IsDesktopBuild)'!='true' and '$(V8TestToolsTask)'!='true' and '%(LocalMetaDataFile.Identity)' != '' "
  SearchPathRoot
="$(OutDir)"
  PathToResultsFilesRoot
="$(TestResultsRoot)"
  MetaDataFile
="%(LocalMetaDataFile.Identity)"
  RunConfigFile
="$(RunConfigFile)"
  TestLists
="%(LocalMetaDataFile.TestList)"
  TestNames
="$(TestNames)"
    ContinueOnError="$(ContinueOnTestError)" />

<!-- 8.0 MetaDataFile tests for non-desktop builds. -->
<
TestToolsTask
   Condition=" '$(IsDesktopBuild)'!='true' and '$(V8TestToolsTask)'=='true' and '%(LocalMetaDataFile.Identity)' != '' "
   SearchPathRoot
="$(OutDir)"
   PathToResultsFilesRoot
="$(TestResultsRoot)"
   MetaDataFile
="%(LocalMetaDataFile.Identity)"
   RunConfigFile
="$(RunConfigFile)"
   TestLists
="%(LocalMetaDataFile.TestList)"
   ContinueOnError
="$(ContinueOnTestError)" />

<!-- TestContainer tests for non-desktop builds. -->
<
TestToolsTask
   Condition
=" '$(IsDesktopBuild)'!='true' and '$(V8TestToolsTask)'!='true' and '@(LocalTestContainer)' != '' "
   SearchPathRoot
="$(OutDir)"
   PathToResultsFilesRoot
="$(TestResultsRoot)"
   RunConfigFile
="$(RunConfigFile)"
   TestContainers
="@(LocalTestContainer)"
   TestNames
="$(TestNames)"
   ContinueOnError
="$(ContinueOnTestError)" />

 <!-- MetaDataFile tests for desktop builds. -->
<
TestToolsTask
   Condition
=" '$(IsDesktopBuild)'=='true' and '$(V8TestToolsTask)'!='true' and '%(MetaDataFile.Identity)' != '' "
   SearchPathRoot
="$(OutDir)"
   PathToResultsFilesRoot
="$(TestResultsRoot)"
   MetaDataFile
="%(MetaDataFile.Identity)"
   RunConfigFile
="$(RunConfigFile)"
   TestLists
="%(MetaDataFile.TestList)"
   TestNames
="$(TestNames)"
   ContinueOnError
="$(ContinueOnTestError)" />

<!-- 8.0 MetaDataFile tests for desktop builds. -->
<
TestToolsTask
   Condition
=" '$(IsDesktopBuild)'=='true' and '$(V8TestToolsTask)'=='true' and '%(MetaDataFile.Identity)' != '' "
   SearchPathRoot
="$(OutDir)"
   PathToResultsFilesRoot
="$(TestResultsRoot)"
   MetaDataFile
="%(MetaDataFile.Identity)"
   RunConfigFile
="$(RunConfigFile)"
   TestLists
="%(MetaDataFile.TestList)"
   ContinueOnError
="$(ContinueOnTestError)" />

  <!-- TestContainer tests for desktop builds. -->
<
TestToolsTask
   Condition
=" '$(IsDesktopBuild)'=='true' and '$(V8TestToolsTask)'!='true' and '@(LocalTestContainer)' != '' "
   SearchPathRoot
="$(OutDir)"
   PathToResultsFilesRoot
="$(TestResultsRoot)"
   RunConfigFile
="$(RunConfigFile)"
   TestContainers
="@(LocalTestContainer)"
   TestNames
="$(TestNames)"
   ContinueOnError
="$(ContinueOnTestError)" />

<!-- Populate TestOutputs with MetaData Files and Test Containers. -->
<
ItemGroup>
   <!--
TestContainer tests for non-desktop and desktop builds. -->
   <
TestOutputs Condition=" '@(LocalTestContainer)' != '' "
                Include
="%(LocalTestContainer.Identity)">
      <
Platform>$(Platform)</Platform>
      <
Configuration>$(Configuration)</Configuration>
   </
TestOutputs>

   <!-- MetaDataFile tests for non-desktop builds. -->
   <
TestOutputs Condition=" '$(IsDesktopBuild)'!='true' and '%(LocalMetaDataFile.Identity)' != '' "
                Include
="%(LocalMetaDataFile.Identity)">
       <
Platform>$(Platform)</Platform>
       <
Configuration>$(Configuration)</Configuration>
   </
TestOutputs>

   <!-- MetaDataFile tests for desktop builds. -->
   <
TestOutputs Condition=" '$(IsDesktopBuild)'=='true' and '%(MetaDataFile.Identity)' != '' "
                Include
="%(MetaDataFile.Identity)">
       <
Platform>$(Platform)</Platform>
       <
Configuration>$(Configuration)</Configuration>
   </
TestOutputs>
</
ItemGroup>
</
Target>

Explanation:

To override CoreTestConfiguration simply locate the Microsoft.TeamFoundation.Build.targets file and copy it from there into your TFSBuild.proj file.

To prevent build from publishing the test results simply remove the values for the following parameters from each instance of the TestToolsTask:

BuildFlavor="$(Configuration)"
Platform="$(Platform)"
PublishServer="$(TeamFoundationServerUrl)"
PublishBuild="$(BuildUri)"
TeamProject="$(TeamProject)"

If these parameters are left off the TestToolsTask the results will not be published.  The test are all executed and the build will fail if any of the test fail.  Note that you will not see the number of passed and failed test in the build report. It appears that the results must be published for that to happen. The results of the test can be reviewed in two ways.  First you can simply open the buildlog.txt file where the list of test and their results are listed.  If you need more detailed information you can locate the trx file in the TestResults folder on the build machine.

Tags: ,

Work

Pingbacks and trackbacks (1)+

About the author

My name is Donovan Brown and I am a process consultant for Imaginet with a background in application development.  I also run one of the Nation’s fastest growing online registration sites for motorsports events DLBRacing.com.  When I am not writing software I race cars for fun.  DLBRacing.com has given me the opportunity to combine my two passions writing software and racing cars.

AdSense

Month List

AdSense