Skip to main content
Skip table of contents

xUnit XML report

This guide explains the basic structure of a xUnit XML report, helping you understand how AgileTest reads and displays report data. Additionally, you can learn how to customize the report to add attachment details.

1. Common structure of xUnit report

Below is the common structure of the xUnit XML report.

In the xUnit report, the structure starts with the <assemblies> element containing multiple <assembly> elements. Inside each assembly, there are collections of tests under the <collection> element, and finally, each test is represented by the <test> element. In case of test failures, the <failure> element includes detailed information such as the stack trace, error message, and the reason for the failure.

image-20260310-022418.png

xUnit test report structure diagram

In a basic xUnit report, you should find common tags depicting test suites and test cases.

xUnit report example
CODE
<assemblies>
  <assembly name="MyApp.Tests" total="5" passed="3" failed="1" skipped="1" time="0.534" errors="0">
    <collection name="MyApp.Tests.CalculatorTests" total="5" passed="3" failed="1" skipped="1" time="0.534">
      <test name="CalculatorTests.Addition_ValidNumbers_ReturnsSum" type="CalculatorTests" method="Addition_ValidNumbers_ReturnsSum" result="Pass" time="0.002" />
      <test name="CalculatorTests.Subtraction_ValidNumbers_ReturnsDifference" type="CalculatorTests" method="Subtraction_ValidNumbers_ReturnsDifference" result="Pass" time="0.003" />
      <test name="CalculatorTests.Division_ByZero_ThrowsException" type="CalculatorTests" method="Division_ByZero_ThrowsException" result="Fail" time="0.001">
        <failure exception-type="System.DivideByZeroException">
          <message>Attempted to divide by zero.</message>
          <stack-trace>
            at MyApp.Calculator.Divide(Int32 x, Int32 y) in C:\MyApp\Calculator.cs:line 42
            at MyApp.Tests.CalculatorTests.Division_ByZero_ThrowsException() in C:\MyApp.Tests\CalculatorTests.cs:line 25
          </stack-trace>
        </failure>
      </test>
      <test name="CalculatorTests.Multiplication_ValidNumbers_ReturnsProduct" type="CalculatorTests" method="Multiplication_ValidNumbers_ReturnsProduct" result="Pass" time="0.001" />
      <test name="CalculatorTests.FeatureNotImplemented_Skipped" type="CalculatorTests" method="FeatureNotImplemented_Skipped" result="Skip" time="0.000">
        <reason>This feature is not implemented yet.</reason>
      </test>
    </collection>
  </assembly>
</assemblies>

Once you understand the structure of a xUnit report, the next step is to see how AgileTest interprets this data when the report is imported. AgileTest reads specific elements in the XML file to create test cases and determine their execution status.

2. How AgileTest would parse an xUnit report

Imported test cases are distinguished by the type and method attributes of the <test> element, following the format: type + ‘.' + method. After parsing, this information appears as the Test Definition in AgileTest and can be found just below the Description area of the test case ticket. The Summary of each test case issue is based on the value of the method attribute.2.1 Supported status tags

Each report file, after execution, contains xUnit status values automatically mapped to AgileTest Test Results. Therefore, you do not need extra setup to read test results.

Below are explanations for the supported status of the xUnit reports in AgileTest.

Prioritization rule for determining the test status in AgileTest:

  • If multiple tags are added to a single <test> element, the tag with the highest priority will be used as the test status in AgileTest.

  • The priority of status tags in AgileTest is as follows: FAILED > BLOCKED > RETEST > SKIPPED > QUERY > PASSED.

In the xUnit report, test case status is calculated based on the status tag in the test tag. The following table shows how xUnit status values are mapped to AgileTest execution statuses.

Test case status

Description

pass, passed

PASSED → Test case yields the expected result.

fail, failed, or error

FAILED → Test case returns the actual result, not as expected.

blocked

BLOCKED → Test case is considered blocked due to a specific reason.

skipped

SKIPPED→ Test case is skipped in the test run.

retest

RETEST → Test case should be rerun again.

query

QUERY → The test case requires more details to have the final result.

todo, to do, or non-defined statuses

TODO → Test case is not yet run. It’s the default status of every Test case in AgileTest.

3. Add attachments in xUnit reports

By default, many reports do not include attachments. This section explains how to add attachments to your test reports.

AgileTest supports 2 customized structures for integrating attachments into your xUnit test reports. Users can choose either option to upload test results along with evidence files.

3.1 Attachment element with name attribute and content inside

To allow AgileTest to recognize attachments in the report, you need to follow a specific XML element structure.

CODE
<attachment name="filename"> base64 content </attachment>

For example, you can put this Element structure into your report like this:

CODE
<test>
  <attachments>
    <attachment name="test.png">iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAQ0lEQVR42u3PQREAAAgDINc/9Mzg14MGZNrOAxERERERERERERERERERERERERERERERERERERERERERERERERERuVh9TJWdbWjzsQAAAABJRU5ErkJggg==</attachment>
  <attachments>
<test>

3.2 Attachment element with separate name and content elements inside

To allow AgileTest to recognize attachments in the report, you can add this element structure:

CODE
<attachment> 
  <name> filename </name>
  <rawcontent> base64 content </rawcontent>
</attachment>

For example, your report will look like:

CODE
<test>
  ...
  <attachments>
    <attachment> 
      <name>test.png</name>
      <rawcontent>iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAQ0lEQVR42u3PQREAAAgDINc/9Mzg14MGZNrOAxERERERERERERERERERERERERERERERERERERERERERERERERERuVh9TJWdbWjzsQAAAABJRU5ErkJggg==</rawcontent>
    </attachment>
  </attachments>
</test>

 


Should you need any assistance or further AgileTest inquiries, please contact us here!

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.