【问题标题】:Fail TFS Build on Single Unit Test Failure单个单元测试失败时 TFS 构建失败
【发布时间】:2010-11-28 21:00:17
【问题描述】:

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

目前,如果构建成功并且单元测试失败,则构建将显示为部分成功。当单元测试失败时,我想将构建显示为失败。

谁能告诉我有没有办法实现这个功能?

【问题讨论】:

    标签: unit-testing tfs continuous-integration


    【解决方案1】:

    如果您在构建机器上安装了 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>
    

    【讨论】:

    • 一旦我安装了 Team Foundation Server 2008 SP1 并在 TFSBuild.proj 的“其他属性”部分中添加了您上面列出的属性,它就可以完美运行。谢谢你的帮助!!!
    猜你喜欢
    • 1970-01-01
    • 2010-11-27
    • 2015-04-25
    • 2018-11-17
    • 1970-01-01
    • 2017-12-04
    • 2011-10-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多