How to show results of individual test pass/fail in Jenkins?

Aaron Shaver picture Aaron Shaver · Nov 13, 2012 · Viewed 24.1k times · Source

We're using Scala + Maven + ScalaTest runner + Jenkins. We have JUnit-style XML output going here:

test_dir/target/scalatest-reports/

Right now we can see entire build pass/fail, or dig through the verbose Console Output to see test pass/fail (not ideal), but I'm sure there's a better way.

I've tried several of the post-build steps such as:

  • Aggregate downstream test results
  • Publish xUnit test result report

But can't get a table of test results working.

Do you have any ideas? Thanks.

Answer

Joost den Boer picture Joost den Boer · Mar 3, 2015

There are two options:

  • ScalaTest can generate HTML reports. Just add

    (testOptions in Test) += Tests.Argument(TestFrameworks.ScalaTest, "-h", "target/scalatest-report")

to your 'build.sbt'. Running 'sbt test' will then generate an HTML report in the folder 'target/scalatest-report'.

In Jenkins you can use the 'Publish HTML' plugin to capture this report for a build. The test html becomes then available for each build and also on job page.

  • ScalaTest also generates normal JUnit XML reports in the 'target/test-reports' folder. The Jenkins these reports can be captured with the 'Publish JUnit XML test report' post-build-action which is default available in Jenkins I think.

Both solutions give a view on the test results and they can be used together.