Using the API's to Link Test Cases and Requirements

Use Case

In the event you have a large number of test cases, linking them manually in the qTest Manager UI will take a considerable amount of time and energy. There comes a tipping point where using the API's becomes a more efficient way of linking your requirements with your test cases.

Tricentis recommends the following as Best Practice when linking Requirements to Test Cases, either from within the UI or via API. 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 at 2,500 and load time will increase.
  • One Requirement linked to 60,001 or more Test Cases: not recommended as the system will become unstable.


This article provides an example of linking your requirements with your test cases using the APIs. In this example, we will use the following:

  • 3 API calls,
  • an online JSON to CSV converter, and
  • Postman's Runner

The online converter will format the APIs, from the standard JSON response format to a CSV format, which allows you to sort the data and use the relevant columns to create a spreadsheet. This spreadsheet can be imported via Postman’s Runner using environment variables to link your requirements to your test cases, going row by row through the final CSV file. 

The majority of the work in this process is aligning your requirements with the associated test cases they need to link to. If you have this information already available in an Excel document or some other form, the majority of the work is already done! If not, you can gather this information using the GET API's listed below.

Use GET API's 

You will need to run both of the appropriate APIs to receive all of the Requirements and Requirement IDs, as well as all of the Test Cases and their corresponding Test Case IDs.

  1. Use this API to get multiple Requirements:
  2. Save your JSON results so you can access them later.
    Example screenshot of the API call in Postman:

  3. Use this API to get multiple Test Cases:
  4. Save your JSON results so you can access them later.
    Example screenshot of the API call in Postman:

Convert JSON API Responses to a CSV Format

You will need to complete these steps for both of the Requirements and Test Cases JSON responses.

Use the following online converter:

Edit CSV Files

  1. You will now have two CSV files. They will look similar to the example below.
  2. Use the "id" filter option found in the Data tab. This allows you to manually remove the filtered rows with a blank Requirement ID field. 
  3. Repeat this process for the Test Cases file as well. 
  4. Now the relevant columns are the "id" columns for both the Requirements and Test Cases CSV file. 
    Hint: Keep the name of the Requirement and Test Case in the files. This will make them more readable and user-friendly.
  5. Create and name a new CSV file, which will be the file where you aggregate your data from your individual Requirements and Test Cases CSV files.
  6. Copy the Requirement Name and Requirement ID column data and paste into the new CSV file.
  7. Copy the Test Case Name and Test Case ID column data and paste into the new CSV file to the right of your Requirement columns.
  8. Now, you need to align the Requirements with the associated Test Cases.
    Hint: Add two blank columns in between your Requirement Name column and your Test Case ID column for 6 columns total. These two new columns allow you to easily cut/paste your Test Case ID and Test Case Name data to align the Requirements. Once you are all finished, you will have 4 columns with data like the image below. 

    Notice the column header names used in the example file above.  These header names will be referenced in the final API call, "requirementid" and "testcaseid."

Create Links Between Objects

  1. Use this API call to link your Requirements to your Test Cases.
  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
    Note: You can read more about how this works here.
  3. Set the API call up using Postman Runner module
    Note: You can read more about how this works here.
  4. Notice the environment variables in the image below, and the header tab is visible:
  5. This image shows the body tab visible:

  6. Save this API to a "collection."
  7. Now you can select the "collection" you created within Postman's Collection Runner module.
  8. In this example, we have called the collection "LinkRUnner." See example configuration image below.
  9. Select your saved collection with the API for linking objects , environment variables, and also the combined CSV file. Once complete, select the Run button. 
  10. If successful, your screen should look similar to this screenshot:

View Requirements in qTest 

Navigate to the Requirements module and check a Requirement in the Resources area. Your Test Cases should now be linked to your Requirements!


Powered by Zendesk