Test reporting

From its initial versions, the JUnit testing framework introduced an XML file format to report the execution of test suites. Over the years, this XML format has become a de facto standard for reporting test results, broadly adopted in the xUnit family.

These XML can be processed by different programs to display the results in a human-friendly format. This is for example what build servers do. For example, Jenkins implements a tool called JUnitResultArchiver, which parses to HTML the XML files resulting from the test execution of a job.

Despite the fact that this XML format has become pervasive, there is no universal formal definition for it. JUnit test executors (for example, Maven, Gradle, and so on) usually use its own XSD (XML Schema Definition). For instance, the structure of this XML report in Maven (http://maven.apache.org/surefire/maven-surefire-plugin/) is as depicted in the following diagram. Note that a test suite is composed by a set of properties and a set of test cases. Each test case can be declared as a failure (test with some assertion failed), skipped (test ignored), and an error (test with an unexpected exception). If none of these states appear in the body of the test suite, then the test is interpreted as successful. Finally, for each test case the XML also stores the standard output (system-out) and the standard error output (system-err):

Schema representation for Maven Surefire XML reports
The rerunFailure is a custom state implemented by Maven Surefire for retrying flaky (intermittent) tests (http://maven.apache.org/surefire/maven-surefire-plugin/examples/rerun-failing-tests.html).

With regards to JUnit 5, the Maven and Gradle plugins used to run Jupiter tests (maven-surefire-plugin and junit-platform-gradle-plugin respectively) write the results of the test execution following this XML format. In the following sections, we are going to see how to transform this XML output to a human readable HTML report.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.132.99