In this section:
Overview
You can configure dotTEST to associate tests with a broad range of development artifacts, such as requirements, defects, tasks, and feature requests.
To successfully associate unit tests with artifacts, you need to:
- Enable the artifact association property.
- Specify issue tracking tags.
- (Optional) Configure their URL associations.
Use the tags in the framework-specific attributes (see Using Attributes for details).
Enabling Artifact Associations
Ensure the report.associations
property is set to true
to enable associations with artifacts. This also enables/disables test associations in the HTML report.
report.associations=true
Specifying Issue Tracking Tags
The following tags for artifact types are associated by default when report associations is enabled:
- asset
- fr (enhancements)
- pr (defects)
- req (user stories)
- task
You can use the issue.tracking.tags
property to define any number of additional tracking tags. Separate tags names with a comma:
issue.tracking.tags=tag1,tag2,tag3
Configuring Issue Tracking Tags and URL Associations
You enable generating a link to the association in the HTML report by configuring the report.assoc.url.tag{n}
option:
report.assoc.url.tag1=[URL]
URLs can contain [%ID%]
or ${id}
variables, which will be replaced by issue identifiers. For example:
report.assoc.url.tag1=http://bugzilla.company.com/show_bug.cgi?id=[%ID%]
Enabling Test Details
You can enable or disable showing test details in the HTML report:
report.contexts_details=[true | false]
The report.contexts_details property must be set to true to enable showing associations.The product’s property file is preconfigured to enable showing test details.
See Report Settings for additional information.
Using Attributes
In order to associate tests with artifacts, use the appropriate framework-specific attribute:
- For NUnit:
NUnit.Framework.PropertyAttribute
(see the NUnit documentation for details about the attribute: http://www.nunit.org/index.php?p=property&r=2.6.3) - For MSTest:
Microsoft.VisualStudio.TestTools.UnitTesting.TestPropertyAttribute
(see the MSDN documentation for details about the attribute: https://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.unittesting.testpropertyattribute.aspx - For xUnit:
Xunit.TraitAttribute
To associate a tag with your tests, place the tag in the attribute specific to the framework:
NUnit
[Property("bug", "1234")] [Test] public void Test() { ... }
MSTest
[TestProperty("bug", "1234")] [Test] public void Test() { ... }
xUnit
[Trait("bug", "1234")] [Fact] public void Test() { ... }
Associating Tags with Classes
All the supported frameworks allow you to associate a tag with a class. As a result, it will be associated with all the tests within this class. In the following example for NUnit, bug 9876 is associated with both tests within the Test class, whereas bug 111 is associated only with the Test2 test:
[Property("bug", "9876")] public class Tests { [Test] public void Test1() { ... } [Property("bug", "111")] [Test] public void Test2() { ... } }
Multiple Associations
All the supported frameworks allow you to associate one tag with more than one artifact. The following example shows multiple associations for the NUnit framework.
[Property("bug", "1234, 1199")] [Test] public void Test() { ... }
You can separate the tasks with a comma, a semicolon or a space character. In the example below, the test is associated with all the listed tasks:
[Property("bug", "1234, 1199; 2345 1928")] [Test] public void Test() { ... }