xUnit.net v2+ XML Format

Several runners—including the console and MSBuild runners—are capable of generating XML reports after tests have been run. Some of those runners also support running XSL-T transformations against that XML (some built-in examples include transformations to HTML and NUnit format). This page documents the format of the XML emitted from v2 (and later) runners.

The schema-version attribute on the assemblies element identifies the schema version of the document. Since this attribute was introduced in schema version 2, it should be assumed that the absence of this attribute implies schema version 1. It's also important to note that schema versions are unrelated to versions of xUnit.net and their runners; you should only make assumptions about supported features in the XML file based on schema-version and not based on the version of xUnit.net.

The top level element of the document is the assemblies element.

Elements

Note: The XML format changed from v1 to v2. If you are looking for documentation on the old v1 format, the xUnit v1 format page contains that documentation.

The assemblies element is the top-level element of the document.

Attributes

Name Schema Value
computer 2+ [Optional] The name of the computer that ran this set of assemblies, if known.
Data type: String
finish-rtf 2+ The time the last assembly finished running, in round-trippable format.
Data type: String (in yyyy-mm-ddThh:mm:ss.fffffff[timezone] format)
id 2+ A unique ID for this collection of assemblies. This ID is regenerated every time the test assemblies are run.
Data type: GUID
schema-version 2+ The schema version of the document.
Data type: Integer
start-rtf 2+ The time the first assembly started running, in round-trippable format.
Data type: String (in yyyy-mm-ddThh:mm:ss.fffffff[timezone] format)
timestamp 2+ The human-readable timestamp of when the last assembly finished running.
Data type: String
user 2+ [Optional] The name of the user that ran this set of assemblies, if known.
Data type: String

Child Elements

Element Schema Cardinality Purpose
<assembly> 1+ 0..* One child element for each test assembly

The assembly element contains information about the run of a single test assembly. This includes environmental information.

Attributes

Name Schema Value
config-file 1+ [Optional] The fully qualified path name of the test assembly configuration file.
Data type: String (file path)
environment 1+ The runtime environment in which the tests were run.
Data type: String
errors 1+ The total number of environmental errors experienced in the assembly. This is separate from failing tests (for example, errors that occurred while cleaning up, between or after tests).
Data type: Integer
failed 1+ The total number of test cases in the assembly which failed.
Data type: Integer
finish-rtf 2+ The time the test assembly finished running, in round-trippable format.
Data type: String (in yyyy-mm-ddThh:mm:ss.fffffff[timezone] format)
id 2+ A unique ID for this test assembly. This ID is regenerated every time the assembly is run.
Data type: GUID
name 1+ The fully qualified path name of the test assembly.
Data type: String (file path)
not-run 2+ The total number of test cases in the assembly that were not run (because they did not match the user's request to run or not run explicit tests).
Data type: Integer
passed 1+ The total number of test cases in the assembly which passed.
Data type: Integer
run-date 1+ The date when the test run started.
Data type: String (in yyyy-mm-dd format)
run-time 1+ The time when the test run started.
Data type: String (in 24-hour hh:mm:ss format)
skipped 1+ The total number of test cases in the assembly that were skipped.
Data type: Integer
start-rtf 2+ The time the test assembly started running, in round-trippable format.
Data type: String (in yyyy-mm-ddThh:mm:ss.fffffff[timezone] format)
target-framework 2+ The target framework that the unit tests were compiled against, if known.
Data type: String (in <FrameworkName>,Version=<FrameworkVersion> format)
test-framework 1+ The display name of the test framework that ran the tests.
Data type: String
time 1+ The number of seconds the assembly run took.
Data type: Decimal
time-rtf 2+ The time spent running tests in the assembly (in a round-trippable format).
Data type: String (in hh:mm:ss.fffffff format)
total 1+ The total number of test cases run in the assembly.
Data type: Integer

Child Elements

Element Schema Cardinality Purpose
<collection> 1+ 0..* One collection element for every test collection in the test assembly.
<errors> 1+ 0..1 Container for the environmental errors experienced in the test assembly.

The collection element contains information about the run of a single test collection.

Attributes

Name Schema Value
id 2+ A unique ID for this test collection. This ID is regenerated every time the collection is run.
Data type: GUID
name 1+ The display name of the test collection.
Data type: String
failed 1+ The total number of test cases in the test collection which failed.
Data type: Integer
not-run 2+ The total number of test cases in the collection that were not run (because they did not match the user's request to run or not run explicit tests).
Data type: Integer
passed 1+ The total number of test cases in the test collection which passed.
Data type: Integer
skipped 1+ The total number of test cases in the test collection that were skipped.
Data type: Integer
time 1+ The number of seconds the test collection run took.
Data type: Decimal
time-rtf 2+ The time spent running tests in the collection (in a round-trippable format).
Data type: String (in hh:mm:ss.fffffff format)
total 1+ The total number of test cases run in the test collection.
Data type: Integer

Child Elements

Element Schema Cardinality Purpose
<test> 1+ 1..* One test element for every test in the test collection.

The error element contains information about an environment failure that happened outside the scope of running a single unit test (for example, an exception thrown while disposing of a fixture object).

Attributes

Name Schema Value
name 1+ [Optional] The name of the item that caused the failure, if known. The value depends on the type of error being reported (for example, for assembly-cleanup the name will be the assembly name, when known).
Data type: String
type 1+ A code which indicates what kind of failure it is.
Data type: Enum (values: assembly-cleanup, fatal, test-case-cleanup, test-class-cleanup, test-cleanup, test-collection-cleanup, test-method-cleanup)

Child Elements

Element Schema Cardinality Purpose
<failure> 1+ 1 Contains information about the failure.

The errors element is a container for 0 or more error elements.

(Note that in schema 2+, the errors element will never be empty; if there are no errors in the collection, then the errors element itself will not be present. Defensively supporting both schema 1 and schema 2+ means you should still plan for errors elements with no children.)

Child Elements

Element Schema Cardinality Purpose
<error> 1+ 0..* One error element for every environmental error that occurred.

The failure element contains information a test failure.

Attributes

Name Schema Value
exception-type 1+ [Optional] The fully qualified type name of the exception that caused the failure.
Data type: String

Child Elements

Element Schema Cardinality Purpose
<message> 1+ 0..1 The composite failure message as a CDATA block.
<stack-trace> 1+ 0..1 The composite stack trace as a CDATA block.

The test element contains information about the run of a single test.

Attributes

Name Schema Value
id 2+ A unique ID for this test. This ID is regenerated every time the test is run.
Data type: GUID
method 1+ [Optional] The name of the method that contained the test.
Data type: String
name 1+ The display name of the test.
Data type: String
result 1+ The result of the test. (Note that while this attribute is present in schema 1, the enum value of NotRun was not introduced until schema 2, and only applies to tests written in xUnit.net v3 or later, when the explicit feature was introduced.)
Data type: Enum (values: Pass, Fail, Skip, and NotRun).
source-file 1+ [Optional] The source file that this test belongs to, if known.
Data type: String (file path)
source-line 1+ [Optional] The source line that this test belongs to, if known.
Data type: Integer
time 1+ The number of seconds the test run took.
Data type: Decimal
time-rtf 2+ The time spent running the test (in a round-trippable format).
Data type: String (in hh:mm:ss.fffffff format)
type 1+ [Optional] The fully qualified type name of the class that contained the test.
Data type: String

Child Elements

Element Schema Cardinality Purpose
<failure> 1+ 0..1 For failing tests, contains information about the failure.
<output> 1+ 0..1 Any output that was written to the test output helper, as a CDATA block.
<reason> 1+ 0..1 For a skipped test, contains the reason text as a CDATA block.
<traits> 1+ 0..1 Container for 1 or more trait elements.
<warnings> 2+ 0..1 Container for 1 or more warning elements.

The trait element contains a single trait name/value pair.

Attributes

Name Schema Value
name 1+ The name of the trait.
Data type: String
value 1+ The value of the trait.
Data type: String

The traits element is a container for 1 or more trait elements.

Child Elements

Element Schema Cardinality Purpose
<trait> 1+ 1..* One trait element for every trait name/value pair associated with the test.

The warnings element is a container for 1 or more warning elements.

Child Elements

Element Schema Cardinality Purpose
<warning> 2+ 1..* Contains a warning message as a CDATA block.
Copyright © .NET Foundation. Contributions welcomed at https://github.com/xunit/xunit/tree/gh-pages.