JUnit style reports#

Canary can generate JUnit XML files for a completed test session. The JUnit XML report format is a standardized structure for representing the results of unit tests, commonly used in continuous integration and continuous deployment (CI/CD) pipelines. This format, which is based on XML (Extensible Markup Language), allows for the systematic recording of test outcomes, including details such as the number of tests run, passed, failed, and skipped, as well as specific error messages and stack traces for failed tests.

A junit report of a test session can be generated after the session has completed:

$ canary run ./basic
...
$ canary report junit create
$ cat junit.xml
<?xml version="1.0" ?>
<testsuites name="Canary Session" tests="2" errors="0" skipped="0" failures="0" time="0.661628" timestamp="2026-06-04T20:43:45">
  <testsuite name="first" tests="1" errors="0" skipped="0" failures="0" time="0.310842" timestamp="2026-06-04T20:43:45">
    <testcase name="first" classname="first" time="0.31084203720092773" file="first/first.pyt"/>
  </testsuite>
  <testsuite name="second" tests="1" errors="0" skipped="0" failures="0" time="0.308708" timestamp="2026-06-04T20:43:46">
    <testcase name="second" classname="second" time="0.30870771408081055" file="second/second.pyt"/>
  </testsuite>
</testsuites>

JUnit spec#

canary supports the following tags and attributes:

<?xml version="1.0" encoding="UTF-8"?>

<!-- <testsuites> Usually the root element of a JUnit XML file.

name        Name of the entire test run (default: Canary session)
tests       Total number of tests in this file
failures    Total number of failed tests in this file
skipped     Total number of skipped tests in this file
time        Aggregated time of all tests in this file in seconds
timestamp   Date and time of when the test run was executed (in ISO 8601 format)
-->

<testsuites name="..." tests="..." failures="..." skipped="..." time="..." timestamp="...">

     <!-- <testsuite> A test suite represents tests in a common folder.

    name        Name of the test suite (folder name)
    tests       Total number of tests in this suite
    failures    Total number of failed tests in this suite
    skipped     Total number of skipped tests in this suite
    time        Aggregated time of all tests in this file in seconds
    timestamp   Date and time of when the test suite was executed (in ISO 8601 format)
    -->
    <testsuite name="..." time="...">
        <!-- <testcase> There are one or more test cases in a test suite.

        name        The name of this test case
        classname   The name of the parent folder (same as the suite's name)
        time        Execution time of the test in seconds
        file        Source code file of this test case
        -->
        <testcase name="..." classname="..." time="..." file="..."/>

        <!-- Test case that failed -->
        <testcase name="..." classname="..." time="..." file="...">

          <!-- <failure> The test failed. -->
          <failure message="..." type="..."> ... </failure>

          <!-- <system-out> Optional data written to standard out for the failed test case. -->
          <system-out> ... </system-out>
        </testcase>

        <!-- Test case that was skipped -->
        <testcase name="..." classname="..." time="..." file="...">

          <!-- <failure> The test failed. -->
          <skipped message="..."/>

        </testcase>
    </testsuite>
</testsuites>