Details and Options
JUnit reports can be imported by other testing tools.
Originally JUnit was exclusive to exporting Java JUnit test reports. However, it is now used by other languages and frameworks like Selenium or Playwright.
JUnit report defines two different types of issues when running tests: "errors" and "failures". A test can only "fail" once, but it can have multiple "errors".
TestObject doesn't define the concept of "error" so this is not used when generating JUnit reports.
In the JUnit report, "hostname" field will always be "Default". "hostname" can be understood like the environment where the tests are being run and this is not something that we can obtain from a
TestReportObject.
By default, test suites will be formed by grouping tests by their "TestFileName" (see the
TestObject documentation details). Tests belonging to the same file name will be considered from the same test suite. If the tests don't define a "TestFileName" field, then a single test suite called "None" will group all the tests in the report.
TestObject "AbsoluteTimeUsed" is used to define the amount of time each test took. Each test suite uses the sum of their tests times to define the total time used. If "AbsoluteTimeUsed" is not available for a specific test, zero is used by default.
Each test failure contains "CDATA" xml block with the expected and actual behavior of the test.
ResourceFunction["GenerateJUnitReport"] takes the following options:
"TestSuiteNameFunction" | Automatic | function that returns the name for each test suite |
"Verbose" | True | whether to include the actual and the expected behavior in the report |
The
"TestSuitNameFunction" function is called with 2 arguments: the file name and a list of
TestObject expression