Share →

It took me longer than I thought it would to find this, but is you are using TFS2008 and you want builds to fail if any of the tests fail then you can add the following to the tests properties group in your build project (TFSBuild.prof)

<PropertyGroup>
  <!-- TEST ARGUMENTS
   If the RunTest property is set to true, then particular tests within a
   metadata file or test container may be specified here.  This is
   equivalent to the /test switch on mstest.exe.

   <TestNames>BVT;HighPriority</TestNames>
  -->
  <TreatTestFailureAsBuildFailure>true</TreatTestFailureAsBuildFailure>
</PropertyGroup>

 

Very handy…

Technorati Tags:    
  • Mike Eshva

    This property actually doesn’t work.

    From http://support.teamprise.com/viewtopic.php?f=8&p=1309

    The TreatTestFailureAsBuildFailure property that was introduced in SP1 does not work for reasons that I am currently tracking down with Microsoft.

  • Martin Hinshelwood

    Works fine if you are using VSTT to do your testing :) . But I see from your link that there are some bugs around using it with JUnit tests…

  • Eshva

    I use the full version (VS Team System 2008 SP1) on workstation and build server. It includes Test component. My unit test are written for MSTest. JUnit uses somebody else :)
    I tried to put this property into test arguments properties section and just under RunCodeAnalysis tag (http://dotnet.org.za/willy/archive/2008/08/19/vsts-tfs2008-service-pack-1-nugget-4-team-build-enhancements.aspx). But in both cases it didn’t the job. Build goes Partialy Complited.

    I repeat Martin’s cite: The TreatTestFailureAsBuildFailure property that was introduced in SP1 does not work for reasons that I am currently tracking down with Microsoft.

    Notice, he will track it down with Microsoft not somebody who has wrote JUnit.

  • Martin Woodward

    Just to clarify, Martin H is correct. The TreatTestFailureAsBuildFailure property works great if you have SP1 installed on your build agent. The problem I was talking about was when running a unit testing mechanism other than the built in MSTest framework, in my instance the JUnit test framework.

    In theory, the TreatTestFailureAsBuildFailure property should make it so that when any build has finished, if the build has been marked with Tests Failing, but with a successful compilation it will mark the build as failed when the property is set to true. However, this only appears to work if the thing setting the test failed property on the build detail is the Team Build logger – not any other code executed inside the TFSBuild.proj file.

    I have sent my analysis off to the Team Build team at Microsoft, and I am waiting a response back. However this is a non critical issues as it only affects people not using the built in test framework, and there is a workaround anyway (which I give in that support post).

    Hope that helps – sorry for the confusion.

    Martin Woodward.

  • HGH For Sale

    I am from Guyana and too bad know English, give true I wrote the following sentence: “And we all heard the stories – international tickets from.”