Howto stop TeamBuild from deploying, if tests fail

Hi,

in TFS B3r a TeamBuild gets deployed, even if tests fail. Since I am also using TB to deploy to our production environment, I would like to let it deploy only, when all tests pass.

How can I achieve this




Answer this question

Howto stop TeamBuild from deploying, if tests fail

  • GvS

    Hi Tilli

    Unfortunately there is no straightway to do this. However you can apply a workaround by editing the Microsoft.TeamFoundation.Build.targets file to get this working.

    1. Set the ContinueOnError="true" flag in the TestToolsTask target to 'false'.

    2. However there is a broader impact of this. On setting this flag as 'false' MSBuild process stops as soon as a test fails. Hence you will run into an issue where some of the log files (like if you had errorswarnings log files) would not get copied and some other targets run post the test task target also wont be run. To avoid this you can do the following - add the OnError flag in the test tools task as follows.

    <TestToolsTask

    Condition=" '$(IsDesktopBuild)'!='false' "

    SearchPathRoot="$(SearchPathRoot)"

    PathToResultsFilesRoot="$(TestResultsRoot)"

    MetaDataFile="%(MetaDataFile.Identity)"

    RunConfigFile="$(RunConfigFile)"

    TestLists="%(MetaDataFile.TestList)"

    ContinueOnError="false" />

    <OnError ExecuteTargets="CopyLogFiles;" />

    </Target>

    Hope this helps

    Thanks

    -Khushboo



  • WCF_Thomas80

    Tilli

    Yes that could definitely be another way

    thanks

    -Khushboo



  • KSchlegel

    thanks for the tip! I will try the OnError. If I'm correct I could set the value of a variable which I can check for in my custom-deploy target, right

  • Howto stop TeamBuild from deploying, if tests fail