Troubleshooting JUnit Test Report Generation in Jenkins for Katalon Tests

Troubleshooting JUnit Test Report Generation in Jenkins for Katalon Tests

26 February 2025 Stephan Petzl Leave a comment Katalon Issues

Integrating Katalon with Jenkins can provide powerful automation and continuous integration capabilities. However, users often encounter issues when generating JUnit test reports, particularly when Jenkins fails to recognize the report files. Here’s a guide to help you troubleshoot and resolve these issues effectively.

Understanding the Problem

When you integrate Katalon with Jenkins, you might encounter an error stating: “Step ‘Publish JUnit test result report’ failed: No test report files were found. Configuration error?” This indicates that Jenkins is unable to locate the test report files in the expected directory.

Common Solutions

1. Correct Path Configuration

Ensure that your test report file paths are correctly configured. If your reports are located in a dynamic folder structure, use a wildcard pattern to match the path. A common pattern that resolves this issue is:

Reports/**/JUnit_Report.xml

This pattern allows Jenkins to locate the JUnit report files regardless of the dynamic folders created during each test execution.

2. Verify Jenkins Executor Settings

In some cases, running multiple Katalon instances simultaneously can lead to this issue. Consider setting the number of executors in Jenkins to 1 to prevent concurrent executions that might interfere with report generation.

3. Script-Based Solutions

If the above solutions don’t work, you might need to implement a script to handle the report files manually. This involves copying reports to a temporary location, renaming them, and moving them back to the JUnit folder. Here’s a sample script:

testCasesTxt = sh (
    script: 'find $WORKSPACE -name "*.ts*" -type f -printf "%f\\n"',
    returnStdout: true
  ).trim()

  testCasesTxt = testCasesTxt.replace(".ts", "")
  testCases = testCasesTxt.split("\\n")

  for (int i = 0; i < testCases.size(); i++) {
    script {
      try {
        wrap([$class: 'Xvfb']) {
          sh """
            cd /opt/katalon
            ./katalon -noSplash -consoleLog -runMode=console -projectPath=$WORKSPACE/"katalon-project.prj" -reportFolder="Reports" -reportFileName="report" -retry=0 -testSuitePath="Test Suites/${testCases[i]}" -executionProfile="qa" -browserType="Chrome"
          """
        }
      } catch (any) {
        currentBuild.result = 'FAILURE'
        throw any
      } finally {
        sh """
          cd /home/environment/tmp/
          cd Reports
          mkdir ${testCases[i]}
          cd $WORKSPACE
          cp -r Reports/ /home/environment/tmp/Reports/${testCases[i]}
          cd /home/environment/tmp/Reports/${testCases[i]}/Reports
          mv JUnit_Report.xml JUnit_Report_${testCases[i]}.xml
          cd $WORKSPACE
          cp -r "Data Files/" "/home/environment/tmp/"
        """
      }
    }
  }

Leverage Repeato for Efficient Test Automation

To streamline your test automation efforts, consider using Repeato, a no-code test automation tool that supports iOS, Android, and web applications. Repeato offers a fast and efficient way to create, run, and maintain automated tests, leveraging computer vision and AI.

With Repeato, you can easily run command line scripts or JavaScript code to automate complex tasks. Its support for data-driven and keyword-driven testing, along with easy version control, makes it a robust alternative to other tools like Katalon, especially for teams looking to overcome common limitations associated with closed-source environments.

For more information on how to get started with Repeato, check out our getting started guide.

Like this article? there’s more where that came from!