CruiseControl,Specflow HTML报告文件合并任务有时会失败

时间:2014-07-17 14:06:35

标签: xml cruisecontrol.net specflow cruisecontrol

我正在尝试使用Specflow html报告进行巡航控制集成测试,但我遇到了一个奇怪的问题。当所有测试通过并且构建成功后,可以按照预期在巡航控制仪表板中查看specflow html报告。但是,如果构建失败(即,如果任何specflow场景未通过),那么当我尝试查看html报告时,巡航控制输出“无法找到文件。”

这是我的ccnet.config的相关部分:

   <publishers>
   <exec>
    <executable>(path)specflow.exe </executable>
    <baseDirectory>(path)</baseDirectory>
    <buildArgs> nunitexecutionreport (path)/(file) 
    /xmlTestResult:(path)\TestResults\testReport_nunit.xml 
    /out:(path)\testReport.html </buildArgs>
    <successExitCodes>0</successExitCodes>
  </exec>
  <merge>
    <files>
      <file>(path)\TestResults\testReport.xml</file>
      <file action="Copy">(path)\TestResults\testReport.html</file>
      <file>(path)\TestResults\codeCoverage.xml</file>
    </files>
  </merge>

1 个答案:

答案 0 :(得分:0)

我有同样的问题。我做的是:

  • 在我的项目标签器中使用incrementOnFailure选项(这样我每个构建都有一个不同的工件目录,成功或失败)
  • url /build/log20141003022201.xml/RetrieveBuildFile.aspx?file=TestResult.html尚未生效,但网址为RetrieveBuildFile.aspx?file = .. / {$ buildNb} /TestResult.html。我有一个旧版本的ccnet(1.5),它可能适用于较新版本。
  • 我写了一个自定义xsl来链接到这个url。这是主要代码

<xsl:if test="contains(//cruisecontrol/parameters/parameter[@name='$CCNetProject']/@value,'Specflow')">
    <!-- hack to have the good path to TestResult.html -->
    <xsl:variable name="buildNb" select="//cruisecontrol/parameters/parameter[@name='$CCNetLabel']/@value" />
    <div style="text-align:right; margin:5px; width:100%;">
      <a href="RetrieveBuildFile.aspx?file=../{$buildNb}/TestResult.html" target="_blank">View this report in its own window</a>
    </div>
    <div>
      <iframe src="RetrieveBuildFile.aspx?file=../{$buildNb}/TestResult.html" border="1" width="100%" height="1000"></iframe>
    </div>
    <!-- /hack-->
</xsl:if>

<xsl:if test="contains(//cruisecontrol/parameters/parameter[@name='$CCNetProject']/@value,'Specflow')"> <!-- hack to have the good path to TestResult.html --> <xsl:variable name="buildNb" select="//cruisecontrol/parameters/parameter[@name='$CCNetLabel']/@value" /> <div style="text-align:right; margin:5px; width:100%;"> <a href="RetrieveBuildFile.aspx?file=../{$buildNb}/TestResult.html" target="_blank">View this report in its own window</a> </div> <div> <iframe src="RetrieveBuildFile.aspx?file=../{$buildNb}/TestResult.html" border="1" width="100%" height="1000"></iframe> </div> <!-- /hack--> </xsl:if>

编辑:我刚刚安装了1.8.5版本,而url /build/log20141003022201.xml/RetrieveBuildFile.aspx?file=TestResult.html效果很好。所以我将我的xsl更改为以下

<xsl:if test="contains(//cruisecontrol/parameters/parameter[@name='$CCNetProject']/@value,'Specflow')">
    <div style="text-align:right; margin:5px; width:100%;">
      <a href="RetrieveBuildFile.aspx?file=TestResult.html" target="_blank">View this report in its own window</a>
    </div>
    <div>
      <iframe src="RetrieveBuildFile.aspx?file=TestResult.html" border="1" width="100%" height="1000"></iframe>
    </div>
</xsl:if>