单个单元测试失败时TFS失败

时间:2009-09-16 16:24:00

标签: unit-testing tfs continuous-integration tfs2008

在Microsoft Team Foundation Server中设置CI,我有一个构建版本,可以构建解决方案并执行解决方案中的所有单元测试。

如果构建成功并且单元测试失败,则构建将显示部分成功。我希望在单元测试失败时将构建显示为失败。

有人能告诉我是否有办法完成此功能?

1 个答案:

答案 0 :(得分:3)

如果您的构建计算机上安装了VS2008 SP1,那么您只需将以下属性添加到TFSBuild.proj文件中即可:

<TreatTestFailureAsBuildFailure>true</TreatTestFailureAsBuildFailure>

如果您没有安装SP1并且您不想安装它,那么您可以按照详细的here by the Dev Lead on the TFS Build team, 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>
相关问题