Menu

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.

Overview

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:
    https://api.qasymphony.com/#/requirement/getRequirements
  2. Save your JSON results so you can access them later.
    Example screenshot of the API call in Postman:
    image1.png

  3. Use this API to get multiple Test Cases:
    https://api.qasymphony.com/#/test-case/getTestCases
  4. Save your JSON results so you can access them later.
    Example screenshot of the API call in Postman:
    image3.png

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:
https://json-csv.com/
image8.png

Edit CSV Files

  1. You will now have two CSV files. They will look similar to the example below.
    image7.png
  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. 
    image2.png
  3. Repeat this process for the Test Cases file as well. 
    image6.png
  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. 
    image10.png

    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.
    https://api.qasymphony.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
    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:
    image9.png
  5. This image shows the body tab visible:
    image5.png

  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.
    image11.png
  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:
    image12.png

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!

image4.png

Powered by Zendesk