This topic explains how to associate tests/code with development artifacts.

Introduction

You can associate your test/code with development artifacts, such as tasks, feature requests, or requirements, to help you track the quality of the application under test. Associations are established by adding Javadoc-like tags to the test code and specifying the development artifact ID. C/C++test includes several default tags, but you can create custom tags to meet your needs. 

The @req and @test are special tags in C/C++test that enable traceability from the test to the artifact in your application lifecycle or requirements management system (ALM/RMS). Parasoft DTP and the Traceability Pack extension for DTP are also required. Refer to the Working with the Requirements View chapter for details on leveraging traceability with Parasoft. 

This chapter covers the basic process of how to apply the association tags.

About Default Tags

The following tags are supported by default:

  • @PR
  • @FR
  • @TASK
  • @REQ - Can be used in the requirements traceability workflow
  • @TEST- Can be used in the requirements traceability workflow

See Using Custom Defect/Issue Tracking Tags for details on creating your own tags.

Creating Associations in Code

You can associate a tests/code with a development artifact by adding a tag followed by the artifact ID as a comment in your code.

  • Do not include other code on the line with the comment.
  • Use only one tag type on a line.
  • Use a comma or a space character to separate multiple artifact IDs.

Examples:

//@REQ 987 333
//@TASK 543, 123
/**
* @req 2453, 198
* @task 2342 156 444
*/

When you create associations for test cases, be sure that the comment is added between the test case makers CPPTEST_TEST_CASE_BEGIN and CPPTEST_TEST_CASE_END.

Example:

/* CPPTEST_TEST_CASE_BEGIN test_foo */
// @FR 903, 555
// @TASK 781
void TestSuite::test_foo()
{
	//test case body
}
/* CPPTEST_TEST_CASE_END test_foo */

Creating Associations During Check-in

You can associate tests/code with development artifacts when checking your files into your source control system. Include a tag and the artifact ID in the commit comment to associate the files with the artifact, for example:

git commit -m "@pr ABC-123"

Creating Associations Using Test Names

As an alternative to using tags, you can associate a test case with a developmentartifact by adding the artifact ID as a suffix to the name of the test case in the following format:

<test case name>_<tag><ID>

In the following example, the test case verifies that bug 3636 has been resolved:

test_case1_PR3636

Using Custom Defect/Issue Tracking Tags

You can customize the tags your team uses to associate a test case with a work item from your ALM, defects, or requirements tracking system (e.g, codeBeamer, Jira, VersionOne, etc.). This allows you to configure the tag to match the language that your organization uses to refer to defects. For instance, some organizations use the term "PR" to refer to a defect. Others use "defect" and would thus prefer to use a custom @defect tag rather than the default @pr tag.

To specify custom tags:

  1. Choose Parasoft> Preferences.
  2. Select Parasoft> Issue Tracking Tags.
  3. Use the available controls to add, modify, or delete tags in the User Issue Tracking Tags table.
    • A tag is followed by one or more values that must be represented by either a single string or a number of strings separated by separator tokens.
    • Separator token values can be any permutation of comma-separated lists of strings and white space-separated lists of strings.

Linking to Correlated Artifacts in Reports

If you want C/C++test reports to link to correlated artifacts, you need to specify URL templates that explain how links to these artifacts are formatted. To do this:

  1. Choose Parasoft> Preferences.
  2. Select Parasoft> Issue Tracking Tags.
  3. In the panel’s top table, specify how links to each artifact type are formatted. For example:

Examples

Example1

This example assumes that your team is using custom issue tracking tags @bugzilla and @defect.

/**
* @pr 2453, 462345
* @bugzilla 2342
* @defect 87766
*/
void testFoo1() {}

The following PR properties will be sent to Parasoft DTP:

2453
462345
2342
87766

Example 2

/**
* @pr 2453, 462345 2342
* 8766 996686776 - these IDs are ignored, because they are not preceded by a tag on the same line
* @pr 87766
*/

The following PR properties will be sent to Parasoft DTP:

2453
462345
2342
87766

Example 3

This example assumes that your team is using custom issue tracking tags @bugzilla and @defect.

/* CPPTEST_TEST_CASE_BEGIN test_foo */ // @pr 123, 456
// @bugzilla 789
// @defect 1357
// @req 7799
void TestSuite::test_foo()
{
//test case body
}
/* CPPTEST_TEST_CASE_END test_foo */

The following PR properties will be sent to Parasoft DTP:

123
456
789
1357
7799

  • No labels