xUnit is a testing framework for .net languages (e.g. C#, F#, VB.NET) mostly focused in unit testing but that can also be used for integration testing.
xUnit works with ReSharper, CodeRush, TestDriven.NET and Xamarin.
Xray supports https://xunit.github.io/docs/format-xml-v2.
xUnit Basic Concepts
In xUnit, you have Tests and Collections. A Collection is a way of aggregating a group of tests, along with their results.
There are 2 types of tests in xUnit:
- Facts are tests which are always true. They test invariant conditions.
- Theories are tests which are only true for a particular set of data.
Both of this types of tests are treated similarly by the results importer.
Importing xUnit XML reports
Below is a simplified example of a xUnit XML report containing a Collection with two Test Cases.
The simplified tags hierarchy of these reports can be represented in the following diagram:
xUnit’s Test Cases are identified by the pair of attributes “type” and “method” attributes.
Test Cases are imported to Xray’s Generic Test issues, and the “type” and “method” attributes are concatenated and mapped to the Generic Test Definition field of the Generic Test.
If a Test already exists with the same Generic Test Definition, then a duplicate is not created.
Test Cases are imported to a new (or user-specified) Test Execution in the context of some project, along with their respective execution results.
Parameterized Tests are imported to the same Test Run, where each set of parameters is identified by a different context.
xUnit’s Test Suites are not mapped to any special entity. However, the execution details screen will show the Test Suite related to a specific test result.
Mapping of fields from the report to the Test issue
|xUnit.net XML report||Test in Jira|
|"method" attribute||Summary field|
|"type" attribute + "." + "method" attribute||Generic Test Definition custom field|
|"value" attribute of the "trait" whose name is "labels" under the <traits> tag, within some <test>, containing one or more labels delimited by space||labels|
|"value" attribute of the "trait" whose name is "test" under the <traits> tag, within some <test>, containing a Jira key of the Test issue||identification of Test issue key in Jira|
|"value" attribute of the "trait" whose name is "requirement" under the <traits> tag, within some <test>, containing one Jira key of the requirement/coverable issue||link to requirement|
- If the "test" Trait contain multiple references to Test entities, only the first instance is considered.
- If the "test" Trait is used explicitly, then the Test must exist; otherwise, it will not be imported.
The status of the Test Run will be set based on the attribute result of the Test:
A non-existent status
Note: Test Cases with the status FAIL may have an error/failure message, which can be seen in the Test Run screen, under the Results section.