Fail TFS Build on Single Unit Test Error

Setting up CI in Microsoft Team Foundation Server, I have an assembly that will build the solution and run all unit tests as part of the solution.

Currently, the build will seem partially successful if the build is successful and the unit test fails. I would like to show the assembly as failed when the unit test fails.

Can someone tell me if there is a way to fulfill this function?

+5
source share
1 answer

If you have VS2008 SP1 installed on your build machine, you can simply add the following property to your TFSBuild.proj file:

<TreatTestFailureAsBuildFailure>true</TreatTestFailureAsBuildFailure>

1 (SP1), , Dev Lead TFS Build, Aaaron Hallberg:

  <Target Name="AfterTest">

    <!-- Refresh the build properties. -->
    <GetBuildProperties TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
                        BuildUri="$(BuildUri)"
                        Condition=" '$(IsDesktopBuild)' != 'true' ">
      <Output TaskParameter="TestSuccess" PropertyName="TestSuccess" />
    </GetBuildProperties>

    <!-- Set CompilationStatus to Failed if TestSuccess is false. -->
    <SetBuildProperties TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
                        BuildUri="$(BuildUri)"
                        CompilationStatus="Failed"
                        Condition=" '$(IsDesktopBuild)' != 'true' and '$(TestSuccess)' != 'true' ">

  </Target>
+3

All Articles