Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-63260

JUnit Plugin still aggregates the results of already cleaned up test reports

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • junit-plugin
    • None
    • Windows 10

      JUnit Plugin still aggregates the results of already cleaned up test reports. From the example below in a declarative pipeline, there are 2 stages each of them starts by cleaning up the reports directory, triggering the build to generate the reports, harvest the results through AbstractTestResultAction.class. The issue is that after running stage 2, the testResultAction.totalCount becomes 5 wherein it should only be 3 since the 2 test cases from the stage 1 were already deleted. 

      If this is something that can't be fixed as it is an expected behavior of the jenkins junit core, is there a way to empty the results that were harvested from the previous stages?

       

       

      stage('1'){  
                   //Insert code to delete test-output directory here
                   //Insert build trigger here with 2 Test Cases
      
                          junit '***/test-output/TEST-com.TestA.xml'
      
                          script {
                              AbstractTestResultAction testResultAction =  currentBuild.rawBuild.getAction(AbstractTestResultAction.class)
                              if (testResultAction != null) {
                                  def totalNumberOfTests = testResultAction.totalCount
                                  def failedNumberOfTests = testResultAction.failCount
                                  def failedDiff = testResultAction.failureDiffString
                                  def skippedNumberOfTests = testResultAction.skipCount
                                  def passedNumberOfTests = totalNumberOfTests - failedNumberOfTests - skippedNumberOfTests
                                  emailTestReport = "Tests Report:\n Passed: ${passedNumberOfTests}; Failed: ${failedNumberOfTests} ${failedDiff}; Skipped: ${skippedNumberOfTests}  out of ${totalNumberOfTests} "
                              }
                          }
                      }
      
                  }
              }
      
      stage('2'){
      
                 //Insert Code to delete test-output directory here
                //Insert build trigger here with 3 Test Cases
                          junit '***/test-output/TEST-com.TestB.xml''
                          script {
                              AbstractTestResultAction testResultAction =  currentBuild.rawBuild.getAction(AbstractTestResultAction.class)
                              if (testResultAction != null) {
                                  def totalNumberOfTests = testResultAction.totalCount
                                  def failedNumberOfTests = testResultAction.failCount
                                  def failedDiff = testResultAction.failureDiffString
                                  def skippedNumberOfTests = testResultAction.skipCount
                                  def passedNumberOfTests = totalNumberOfTests - failedNumberOfTests - skippedNumberOfTests
                                  emailTestReport = "Tests Report:\n Passed: ${passedNumberOfTests}; Failed: ${failedNumberOfTests} ${failedDiff}; Skipped: ${skippedNumberOfTests}  out of ${totalNumberOfTests} "
                              }
                          }
                      }
      
                  }
              }
      

       

            Unassigned Unassigned
            kdpanaglima kevin pan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: