XML Format

This guide explains the full JUnit-style XML support in Testmo to easily submit test automation results with any tool and platform.

Testmo supports JUnit-style XML files to read and submit test results. The advantage of this format is that it is supported by any test automation tool (directly or indirectly) and it has become the de facto standard format to exchange test results between tools. You can find examples for many automation tools in our integration documentation.

Testmo also supports various extensions of this format to include test field properties (fields) as well as attachments. And Testmo can alternatively also detect and read properties from the standard and error outputs in XML files (to support tools without dedicated property support).

Additionally, Testmo supports various fields and field types for properties included in XML files. On this page we are showing all tags, fields, types and conventions supported by Testmo.

Full XML example files

Below we are including two XML example files that showcase all supported features. In practice you wouldn't usually mix all these different fields and options. This examples are useful to see all supported conventions and fields in one place. Also see our test field documentation and full HTML reference to learn more about supported features.

Example using properties

<?xml version="1.0" encoding="UTF-8"?>
<!--
This is a full example file that shows the various tags, attributes, fields, types
and conventions supported by Testmo.
-->
<testsuites name="Test run" tests="8" failures="1" errors="1" skipped="1"
    assertions="20" time="16.082687" timestamp="2021-04-02T15:48:23">
    <testsuite name="Tests.Registration" tests="8" failures="1" errors="1" skipped="1"
        assertions="20" time="16.082687" timestamp="2021-04-02T15:48:23"
        file="tests/registration.code">

        <!-- Passing tests -->
        <testcase name="testCase1" classname="Tests.Registration" assertions="2"
            time="2.436" file="tests/registration.code" line="24" />
        <testcase name="testCase2" classname="Tests.Registration" assertions="6"
            time="1.534" file="tests/registration.code" line="62" />
        <testcase name="testCase3" classname="Tests.Registration" assertions="3"
            time="0.822" file="tests/registration.code" line="102" />

        <!-- A skipped test -->
        <testcase name="testCase4" classname="Tests.Registration" assertions="0"
            time="0" file="tests/registration.code" line="164">
            <skipped message="Test was skipped." />
        </testcase>

        <!-- A failing test -->
        <testcase name="testCase5" classname="Tests.Registration" assertions="2"
            time="2.902412" file="tests/registration.code" line="202">
            <failure message="Expected value did not match." type="AssertionError">
                Stack trace ..
            </failure>
        </testcase>

        <!-- A test with errors -->
        <testcase name="testCase6" classname="Tests.Registration" assertions="0"
            time="3.819" file="tests/registration.code" line="235">
            <error message="Division by zero." type="ArithmeticError">
                Stack trace ..
            </error>
        </testcase>

        <!-- Example of a test case with outputs -->
        <testcase name="testCase7" classname="Tests.Registration" assertions="3"
            time="2.944" file="tests/registration.code" line="287">
            <!-- <system-out> Optional data written to standard out -->
            <system-out>Data written to standard out.</system-out>

            <!-- <system-err> Optional data written to standard error -->
            <system-err>Data written to standard error.</system-err>
        </testcase>

        <!-- Example of a test case with properties -->
        <testcase name="testCase8" classname="Tests.Registration" assertions="4"
            time="1.625275" file="tests/registration.code" line="302">

            <properties>
                <!-- Regular basic properties and values -->
                <property name="priority" value="high" />
                <property name="author" value="Adrian" />

                <!-- Example for a property with text value -->
                <property name="description"><![CDATA[
                    This text describes the purpose of this test case and provides
                    an overview of what the test does and how it works.
                ]]></property>

                <!-- Examples for different type hints -->
                <property name="string:priority" value="high" />
                <property name="url:github" value="https://github.com/project/code.js" />
                <property name="text:description" value="Long text field.." />
                <property name="console:log"><![CDATA[
                    Log line #1
                    Log line #2
                    Log line #3
                ]]></property>
                <property name="html:richtext"><![CDATA[
                    <h1>Title</h1>
                    <p>Text</p>
                ]]></property>

                <!-- Testmo also supports step fields: -->

                <!-- Either use multiple properties named "step" -->
                <property name="step" value="This is the first step." />
                <property name="step" value="And this is the second step." />

                <!-- Or append a unique index if your test framework requires this -->
                <property name="step1" value="Testmo will automatically index the steps." />
                <property name="step2" value="And this is another test step." />

                <!-- Some tools support multi-line properties. Steps always support HTML -->
                <property name="step"><![CDATA[
                    This is a more complex test step with <strong>multiple lines</strong>
                    of text using a property with a text value.
                ]]></property>

                <!-- You can optionally also include a step result status as part
                of the property name in square brackets. All status automation 
                aliases as configured in Testmo under Admin > Statuses work. -->
                <property name="step[passed]" value="This is a test step that passed." />
                <property name="step[failure]" value="And this step had a failure." />
                <property name="step[skipped]" value="This step wasn't executed." />
                <property name="step[error]" value="And this step had an error." />

                <!-- Testmo also supports step sub fields using the following special tags. -->
                <property name="step[passed]"><![CDATA[
                    <test-step-subfield name="Step">
                        This line describes this step. You can also use <strong>HTML</strong>.
                    </test-step-subfield>
                    <test-step-subfield name="Expected">
                        You can optionally include more sub fields, e.g. for the expected results.
                    </test-step-subfield>
                ]]></property>

                <!-- Testmo also supports attachment fields: -->

                <!-- Either use multiple properties named "attachment" -->
                <property name="attachment" value="https://ci/files/22-dashboard.png" />
                <property name="attachment" value="https://ci/files/23-users.png" />

                <!-- Or append a unique index if your test framework requires this -->
                <property name="attachment1" value="https://ci/files/24-sessions.png" />
                <property name="attachment2" value="https://ci/files/25-failure.png" />
            </properties>
        </testcase>
    </testsuite>
</testsuites>

Example using outputs

<?xml version="1.0" encoding="UTF-8"?>
<!--
This is a full example file that shows the various tags, attributes, fields, types
and conventions supported by Testmo.
-->
<testsuites name="Test run" tests="8" failures="1" errors="1" skipped="1"
    assertions="20" time="16.082687" timestamp="2021-04-02T15:48:23">
    <testsuite name="Tests.Registration" tests="8" failures="1" errors="1" skipped="1"
        assertions="20" time="16.082687" timestamp="2021-04-02T15:48:23"
        file="tests/registration.code">

        <!-- [...] -->

        <!-- Example of a test case with properties in the output -->
        <testcase name="testCase8" classname="Tests.Registration" assertions="4"
            time="1.625275" file="tests/registration.code" line="302">

            <system-out><![CDATA[
# Single line properties
[[PROPERTY|author=Adrian]]
[[PROPERTY|language=english]]

# Multi-line properties
[[PROPERTY|browser-log]]
Log line #1
Log line #2
Log line #3
[[/PROPERTY]]

# Examples for different type hints

[[PROPERTY|string:priority=high]]
[[PROPERTY|url:github=https://github.com/project/code.js]]
[[PROPERTY|text:description=Long text field..]]

[[PROPERTY|console:log]]
Log line #1
Log line #2
Log line #3
[[/PROPERTY]]

[[PROPERTY|html:richtext]]
<h1>Title</h1>
<p>Text</p>
[[/PROPERTY]]

# Testmo also supports step fields:

# Either use multiple properties named "step"
[[PROPERTY|step=This is the first step.]]
[[PROPERTY|step=And this is the second step.]]

# Multi-line properties also work. Steps always support HTML
[[PROPERTY|step]]
    This is a more complex test step with <strong>multiple lines</strong>
    of text using a property with a text value.
[[/PROPERTY]]

# You can optionally also include a step result status as part
# of the property name in square brackets. All status automation 
# aliases as configured in Testmo under Admin > Statuses work.
[[PROPERTY|step[passed]=This is a test step that passed.]]
[[PROPERTY|step[failure]=And this step had a failure.]]
[[PROPERTY|step[skipped]=This step wasn't executed.]]
[[PROPERTY|step[error]=And this step had an error.]]

# Testmo also supports step sub fields using the following special tags.
[[PROPERTY|step[passed]]]
    <test-step-subfield name="Step">
        This line describes this step. You can also use <strong>HTML</strong>.
    </test-step-subfield>
    <test-step-subfield name="Expected">
        You can optionally include more sub fields, e.g. for the expected results.
    </test-step-subfield>
[[/PROPERTY]]

# Testmo also supports attachment fields:

# Either use multiple properties named "attachment"
[[PROPERTY|attachment=https://ci/files/22-dashboard.png]]
[[PROPERTY|attachment=https://ci/files/23-users.png]]

# Or append a unique index if your test framework requires this
[[PROPERTY|attachment1=https://ci/files/24-sessions.png]]
[[PROPERTY|attachment2=https://ci/files/25-failure.png]]

# Or use the common attachment syntax used by many tools
[[ATTACHMENT|https://ci/files/25-admin.png]]
[[ATTACHMENT|https://ci/files/26-login.png]]
            ]]></system-out>
        </testcase>
    </testsuite>
</testsuites>

Last updated