Use APIs to Link Test Cases to Requirements

When you have a large number of Test Cases in qTest Manager, manually linking the Test Cases to Requirements can take a considerable amount of time and effort. To more efficiently link large quantities of Test Cases, you can use APIs. This article provides an example walkthrough of linking Test Cases to Requirements using the qTest APIs. Following is an overview of the procedure steps.

  1. Receive Test Cases and Requirements using GET APIs

  2. Convert the JSON API responses to a .csv format

  3. Create a master spreadsheet

  4. Link Test Cases to Requirements using an API

  5. View Requirements in qTest

Tricentis recommends the following limits as best practices when linking Test Cases to Requirements, whether using the UI or APIs. Note the maximum thresholds and associated impact. These numbers are generalized for providing context.

  • One Requirement linked to 2,500 Test Cases: Expect difficult navigation within the UI and increased load time.

  • One Requirement linked to 60,001 or more Test Cases: Not recommended, as the system may become unstable.

Receive Test Cases and Requirements using GET APIs

Use GET APIs to receive all of the Requirements, Requirement IDs, Test Cases, and Test Case IDs in a JSON format.

Receive Requirements

  1. Use the following API to receive Requirements: https://qtest.dev.tricentis.com/#/requirement/getRequirements

  2. Save the JSON results so that you can access them later.

Following is an example image of the API call in Postman.

Receive Test Cases

  1. Use the following API to receive Test Cases: https://qtest.dev.tricentis.com/#/test-case/getTestCases

  2. Save the JSON results so that you can access them later.

Following is an example image of the API call in Postman.

Convert the JSON API responses to a .csv format

Use the online converter at https://json-csv.com/ to convert the JSON results to a .csv file. Complete the process for both the Test Cases results and the Requirements results.

Once the results are converted, the .csv files should look similar to the following example.

Create a master spreadsheet

Filter and copy the data in the .csv files to create a master spreadsheet that can be imported to qTest Manager using the Postman Collection Runner.

  1. In the Requirements .csv file, use the Excel Filter option in the ID column to remove any rows that do not have an entry in the ID column.

    For additional information about using the Excel Filter option, refer to the Microsoft Excel Support website.

  2. Repeat step 1 for the Test Cases .csv file.

  3. Create a new .csv file. This .csv file will be the master spreadsheet where you will combine data from the Requirements and Test Cases .csv files.

  4. In the Requirements .csv file, copy the Name and ID columns. Then paste the columns in the master spreadsheet.

  5. In the Test Cases .csv file, copy the Name and ID columns. Then paste the columns to the right of the Requirements columns in the master spreadsheet.

  6. Align the Requirements with the associated Test Cases. We recommend adding two blank columns between the Requirements columns and the Test Cases columns. The two blank columns can then be used to cut and paste the data, as needed.

    Once you are finished, the master spreadsheet should include four columns that look similar to the following image.

  7. Rename the columns to use the following headers. These header names will be referenced in a subsequent API.

    • requirementid

    • requirement

    • testcaseid

    • test case

Link Test Cases to Requirements using an API

  1. Use the following API to link the Requirements to the Test Cases: https://qtest.dev.tricentis.com/#/object-link/linkArtifacts

  2. Use environment variables to specify the Requirement ID and Test Case ID that will be substituted to the corresponding value in the .csv file

    For additional information about using variables in Postman, refer to the Postman Learning Center.
  3. Set the API call up using the Postman Collection Runner.

    For additional information about the Postman Collection Runner, refer to the Postman blog.

    Following is an example image of environment variables. This image displays the Headers tab.

    The following image displays the Body tab.

  4. Save the API to a Postman Collection Runner collection.

    For additional information about Postman collections, refer to the Postman Learning Center.

    The following image displays an example collection called "LinkRunner".

  5. Click the Run button.

    Once the collection is successfully run, the Postman Collection Runner will indicate that the API was successful.

View Requirements in qTest

The Test Cases are now linked to the Requirements in qTest Manager.

To verify the links:

  1. Access qTest Manager.

  2. Click the Requirements tab.

  3. Select a Requirement in the tree panel.

    The Resources section on the Requirements screen displays the linked Test Cases.