Skip to main content
Skip table of contents

NUnit XML report

About NUnit

image-20241204-085654.png

NUnit is a unit-testing framework for all .Net languages. NUnit is Open Source software. This framework is very easy to work with and has user friendly attributes for working.

Common structure

In a basic NUnit report, you will find common tags representing test suites and test cases. Below are examples of test results in NUnit 2.6 and NUnit 3 formats:

NUnit 2.6 format

NUnit 2.6 report example
XML
<?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>

To visualize the structure more clearly, let’s take a look at below diagram.

image (7)-20241210-090835.png

NUnit 2.6 test report structure diagram

NUnit 3 format

NUnit 3 report example
XML
<?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>

To visualize the structure more clearly, let’s take a look at below diagram.

image (8)-20241210-091523.png

NUnit 3 test report structure diagram

How AgileTest would parse an NUnit report

In AgileTest, all test cases imported using the automation feature are classified as Generic Tests.

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.

Supported status tags

Test run status tag

Description

<pass>, <passed>, <success> or no tag

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.

The priority of status tags in AgileTest is as follows:

failed > blocked > retest > skipped > query > passed (or no tag).

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.

Test result with attachments

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

1. Attachment element with name attribute and content inside

Element structure
XML
<attachment name="filename"> base64 content </attachment>
Example
XML
<test-case>
  ...
  <attachments>
    <attachment name="test.png">iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAQ0lEQVR42u3PQREAAAgDINc/9Mzg14MGZNrOAxERERERERERERERERERERERERERERERERERERERERERERERERERuVh9TJWdbWjzsQAAAABJRU5ErkJggg==</attachment>
  </attachments>
<test-case>

2. Attachment element with separate name and content elements inside

Element structure
XML
<attachment> 
  <name> filename </name>
  <rawcontent> base64 content </rawcontent>
</attachment>
Example
XML
<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.