Skip to main content
Skip table of contents

NUnit XML report

This guide explains the basic structure of a NUnit 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 NUnit report

Below is the common structure of the NUnit XML report. The following sections illustrate the common formats used in NUnit 2.6 and NUnit 3.

1.1 NUnit 2.6 format

In an NUnit 2.6 report, test results are organized into test suites and test cases. The report uses the <test-results> element to group multiple <test-suite> elements. Each test suite can contain several test cases.

image-20260309-092349.png

NUnit 2.6 test report structure diagram

In a basic NUnit report, you will find common tags representing test suites and test cases.

NUnit 2.6 report example
CODE
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<test-results name="C:\Tests\MyTests.dll" total="3" errors="0" failures="2" not-run="0" inconclusive="0" ignored="0" skipped="0" invalid="0" date="2024-12-16" time="10:00:00">
  <environment nunit-version="2.6.4" clr-version="4.0.30319.42000" os-version="Microsoft Windows NT 10.0.19045.0" platform="Win32NT" cwd="C:\Tests" machine-name="MyMachine" user="User" user-domain="MYDOMAIN" />
  <culture-info current-culture="en-US" current-uiculture="en-US" />
  <test-suite type="Assembly" name="MyTests.dll" executed="True" result="Failure" success="False" time="0.35" asserts="3">
    <results>
      <test-suite type="TestFixture" name="CalculatorTests" executed="True" result="Failure" success="False" time="0.35" asserts="3">
        <results>
          <test-case name="AdditionTest" executed="True" result="Success" success="True" time="0.15" asserts="1">
            <reason>
              <message>Test passed successfully.</message>
            </reason>
          </test-case>
          <test-case name="SubtractionTest" executed="True" result="Failure" success="False" time="0.1" asserts="1">
            <failure>
              <message><![CDATA[Expected: 2 But was: 3]]></message>
              <stack-trace><![CDATA[
                at MyTests.CalculatorTests.SubtractionTest() in C:\Tests\CalculatorTests.cs:line 20
              ]]></stack-trace>
            </failure>
          </test-case>
          <test-case name="DivisionTest" executed="True" result="Failure" success="False" time="0.1" asserts="1">
            <failure>
              <message><![CDATA[Attempted to divide by zero.]]></message>
              <stack-trace><![CDATA[
                at MyTests.CalculatorTests.DivisionTest() in C:\Tests\CalculatorTests.cs:line 30
              ]]></stack-trace>
            </failure>
          </test-case>
        </results>
      </test-suite>
    </results>
  </test-suite>
</test-results>

1.2 NUnit 3 format

In the NUnit 3 report, test results are organized into test runs, test suites, and test cases. The report starts with the <test-run> element that contains multiple <test-suite> elements. Each test suite can further contain multiple <test-case> elements.

NUnit 3 report example
CODE
<?xml version="1.0" encoding="utf-8"?>
<test-run id="2" name="SampleTestSuite" testcasecount="3" result="Failed" total="3" passed="2" failed="1" inconclusive="0" skipped="0" asserts="3" start-time="2024-12-04T12:00:00" end-time="2024-12-04T12:00:01" duration="0.123">
  <environment framework-version="3.13.0" clr-version="4.0.30319.42000" os-version="Microsoft Windows NT 10.0.19045.0" platform="x86" cwd="C:\Tests" machine-name="TestMachine" user="TestUser" user-domain="TestDomain" />
  <test-suite type="TestSuite" id="0-0" name="SampleTestSuite" fullname="SampleTestSuite" result="Failed" duration="0.123" asserts="3">
    <properties>
      <property name="Category" value="ExampleCategory" />
    </properties>
    <test-case id="0-0-1" name="Test1" fullname="SampleTestSuite.Test1" methodname="Test1" classname="SampleTest" result="Passed" duration="0.045" asserts="1" />
    <test-case id="0-0-2" name="Test2" fullname="SampleTestSuite.Test2" methodname="Test2" classname="SampleTest" result="Failed" duration="0.032" asserts="1">
      <failure>
        <message><![CDATA[Expected: 5 But was: 4]]></message>
        <stack-trace><![CDATA[at SampleTest.Test2() in C:\Tests\SampleTest.cs:line 25]]></stack-trace>
      </failure>
    </test-case>
    <test-case id="0-0-3" name="Test3" fullname="SampleTestSuite.Test3" methodname="Test3" classname="SampleTest" result="Passed" duration="0.046" asserts="1" />
  </test-suite>
</test-run>

 

image-20260309-092440.png

NUnit 3 test report structure diagram

Once you understand the structure of an NUnit 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 NUnit report

Imported test cases are distinguished by the name attribute of the <test-case> element parsed from the XML file. This information appears as the Test Definition in AgileTest after parsing and can be found just below the Description section of the test case ticket. The Summary of each test case issue is based on the value of the name attribute.

Each report file, after execution, contains NUnit 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 NUnit reports in AgileTest.

Prioritization rule for determining the test status in AgileTest:

  • If multiple tags are added to a single <test-case> 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 NUnit report, test case status is calculated based on the status tag in the test-case tag. The following table shows how NUnit status values are mapped to AgileTest execution statuses.

Test case status

Description

pass, passed, success

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 NUnit 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 NUnit 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-case>
  ...
  <attachments>
    <attachment name="test.png">iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAQ0lEQVR42u3PQREAAAgDINc/9Mzg14MGZNrOAxERERERERERERERERERERERERERERERERERERERERERERERERERuVh9TJWdbWjzsQAAAABJRU5ErkJggg==</attachment>
  </attachments>
<test-case>

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-case>
  ...
  <attachments>
    <attachment> 
      <name>test.png</name>
      <rawcontent>iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAQ0lEQVR42u3PQREAAAgDINc/9Mzg14MGZNrOAxERERERERERERERERERERERERERERERERERERERERERERERERERuVh9TJWdbWjzsQAAAABJRU5ErkJggg==</rawcontent>
    </attachment>
  </attachments>
</test-case>

 


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.