如何在Jenkins测试结果中显示PASSED测试

时间:2016-03-08 17:00:17

标签: jenkins junit

一旦Jenkins工作完成,它将显示所有和失败的测试,但没有通过测试。我的邮件通知需要这个。这里有一个所有通过测试的列表会更方便我: enter image description here

1 个答案:

答案 0 :(得分:0)

请允许我自己回答:您只需要更新现有的html emial通知:https://github.com/jenkinsci/email-ext-plugin/blob/master/src/main/resources/hudson/plugins/emailext/templates/html.jelly 阅读本文也知道放置新文件的位置: https://wiki.jenkins-ci.org/pages/viewpage.action?pageId=59506969 复制文件的这一部分

<!-- JUnit TEMPLATE -->

<j:set var="junitResultList" value="${it.JUnitTestResult}" />
<j:if test="${junitResultList.isEmpty()!=true}">
  <TABLE width="100%">
    <TR><TD class="bg1" colspan="2"><B>JUnit Tests</B></TD></TR>
    <j:forEach var="junitResult" items="${it.JUnitTestResult}">
      <j:forEach var="packageResult" items="${junitResult.getChildren()}">
        <TR><TD class="bg2" colspan="2"> Name: ${packageResult.getName()} Failed: ${packageResult.getFailCount()} test(s), Passed: ${packageResult.getPassCount()} test(s), Skipped: ${packageResult.getSkipCount()} test(s), Total: ${packageResult.getPassCount()+packageResult.getFailCount()+packageResult.getSkipCount()} test(s)</TD></TR>
        <j:forEach var="failed_test" items="${packageResult.getFailedTests()}">
          <TR bgcolor="white"><TD class="test_failed" colspan="2"><B><li>Failed: ${failed_test.getFullName()} </li></B></TD></TR>
        </j:forEach>
      </j:forEach> 
    </j:forEach>  
  </TABLE>  
<BR/>
</j:if>

再次粘贴并稍微改变一下:

<!-- JUnit TEMPLATE -->

<j:set var="junitResultList" value="${it.JUnitTestResult}" />
<j:if test="${junitResultList.isEmpty()!=true}">
  <TABLE width="100%">
    <TR><TD class="bg1" colspan="2"><B>JUnit Tests</B></TD></TR>
    <j:forEach var="junitResult" items="${it.JUnitTestResult}">
      <j:forEach var="packageResult" items="${junitResult.getChildren()}">
        <TR><TD class="bg2" colspan="2"> Name: ${packageResult.getName()} Failed: ${packageResult.getFailCount()} test(s), Passed: ${packageResult.getPassCount()} test(s), Skipped: ${packageResult.getSkipCount()} test(s), Total: ${packageResult.getPassCount()+packageResult.getFailCount()+packageResult.getSkipCount()} test(s)</TD></TR>
        <j:forEach var="passed_test" items="${packageResult.getPassedTests()}">
          <TR bgcolor="white"><TD class="test_passed" colspan="2"><B><li>Passed: ${passed_test.getFullName()} </li></B></TD></TR>
        </j:forEach>
      </j:forEach> 
    </j:forEach>  
  </TABLE>  
<BR/>
</j:if>