Back to Xunit

xUnit.net XML Format v2

site/docs/format-xml-v2.md

latest13.4 KB
Original Source

xUnit.net XML Format v2

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.

[!NOTE] Any child element that doesn't link to specific documentation is an element that contains text, rather than child elements and/or attributes. Older runners will place this text in a CDATA block; newer runners will just put the text directly into the element. XSL-T (and most parsers) won't differentiate between naked text vs. a CDATA block.

[!NOTE] If you are looking for documentation on the deprecated XML format supported by xUnit.net v1, see the xUnit.net XML Format v1 documentation page.

<assemblies>{ #assemblies }

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

AttributeSchemaValue
computer2+[Optional] The name of the computer that ran this set of assemblies.

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

ChildSchemaCardinalityPurpose
<assembly>1+0..*One assembly element for each test assembly

<assembly>{ #assembly }

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

AttributeSchemaValue
config-file1+[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+ | [Optional] The target framework that the unit tests were compiled against. 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

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

<collection>{ #collection }

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

AttributeSchemaValue
failed1+The total number of test cases in the test collection which failed.

Data type: Integer

| 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 | 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

ChildSchemaCardinalityPurpose
<test>1+1..*One test element for every test in the test collection.

<error>{ #error }

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).

AttributeSchemaValue
name1+[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")

ChildSchemaCardinalityPurpose
<failure>1+1Contains information about the failure.

<errors>{ #errors }

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

[!NOTE] 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.

ChildSchemaCardinalityPurpose
<error>1+0..*One error element for every environmental error that occurred.

<failure>{ #failure }

The failure element contains information a test failure.

AttributeSchemaValue
exception-type1+[Optional] The fully qualified type name of the exception that caused the failure.

Data type: String

ChildSchemaCardinalityPurpose
<message>1+0..1The composite failure message.
<stack-trace>1+0..1The composite stack trace.

<test>{ #test }

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

AttributeSchemaValue
finish-rtf3+[Optional] The time the test 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. 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 | start-rtf | 3+ | [Optional] The time the test started running, in round-trippable format. Data type: String (in yyyy-mm-ddThh:mm:ss.fffffff[timezone] format) | 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

ChildSchemaCardinalityPurpose
<failure>1+0..1For failing tests, contains information about the failure.
<output>1+0..1Any captured output.
<reason>1+0..1For a skipped test, contains the reason text.
<traits>1+0..1Container for 1 or more trait elements.
<warnings>2+0..1Container for 1 or more warning elements.

<trait>{ #trait }

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

AttributeSchemaValue
name1+The name of the trait.

Data type: String

| value | 1+ | The value of the trait. Data type: String

<traits>{ #traits }

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

ChildSchemaCardinalityPurpose
<trait>1+1..*One trait element for every trait name/value pair associated with the test.

<warnings>{ #warnings }

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

ChildSchemaCardinalityPurpose
<warning>2+1..*One warning element for each warning message in the test.