Apidog

All-in-one Collaborative API Development Platform

API Design

API Documentation

API Debugging

API Mock

API Automated Testing

Sign up for free
Home / Tutorials / Best Practice: Streamlining API Test Orchestration with "Dynamic Values" in Apidog

Best Practice: Streamlining API Test Orchestration with "Dynamic Values" in Apidog

Passing data efficiently between test steps is crucial in automated testing. Traditional methods are often time-consuming and error-prone. Apidog's "dynamic value" mechanism automates data passing, enhancing API test orchestration and reducing maintenance efforts.

When orchestrating automated API tests, efficiently passing data between test steps is crucial. Traditional methods often involve manually copying and pasting data or configuring complex scripts, which can be time-consuming, error-prone, and difficult to maintain. Apidog introduces a "dynamic value" transmission mechanism to address these challenges.

What is Test Orchestration?

In the realm of software development and quality assurance, the coordination and automation of various testing activities play a pivotal role in ensuring the reliability and functionality of applications. Test orchestration, a critical aspect of the testing process, involves the systematic arrangement and execution of test cases, scripts, and procedures to achieve comprehensive and efficient testing outcomes.

Test orchestration serves as the backbone of the testing process, enabling teams to manage, schedule, and automate testing activities across multiple environments and platforms. By orchestrating tests effectively, organizations can enhance testing coverage, reduce manual efforts, and accelerate the testing cycle, ultimately leading to faster releases and improved software quality.

The Biggest API Test Orchestration Challenge

The most significant challenge in API test orchestration is efficient data management. This challenge encompasses several critical aspects:

1. Data Dependencies

  • Inter-Step Data Transfer: Ensuring that data generated or modified in one API test step is correctly and efficiently passed to subsequent steps. This often involves handling complex data dependencies, which can be cumbersome and error-prone when done manually.
  • Consistency and Accuracy: Maintaining consistent and accurate data flow across various test steps and scenarios. Inconsistent data can lead to test failures and unreliable results.

2. Dynamic Data Handling

  • Real-Time Data Adaptation: The ability to adapt to changing data in real-time is crucial. Traditional methods often lack the flexibility to dynamically handle data changes, leading to outdated or irrelevant API test inputs.

3. Scalability

  • Managing Large Test Suites: As the number of tests grows, efficiently managing data across numerous test cases becomes increasingly complex. Scalability issues can arise, making it difficult to maintain and execute large test suites effectively.

4. Maintainability

  • Handling Changes in API and Business Logic: Frequent changes in API endpoints or business logic require updates to API test cases and their data dependencies. Efficiently managing these updates is challenging and can lead to increased maintenance efforts.

The Power of Apidog's Dynamic Values

Dynamic values at Apidog act as a flexible "bridge", capturing the data of specified "upstream" test steps(pre-step) and inserting them into the request parameters of "downstream" test steps (current step). This mechanism ensures that API test cases adapt seamlessly to data changes across different scenarios, eliminating manual data transmission and significantly reducing the potential for errors.

Setting Up Dynamic Values in Apifox:

1. Define Parameter Values:

  • Click the "magic wand" icon in the interface details of the API automated test.
  • Select the "Read the running results of the previous step" option.
Retrieve pre-step data at Apidog

2. Select the Upstream Data Source:

  • Choose a pre-step from which to extract data.
  • Extract necessary data, such as request parameters (headers, body) and response data (headers, body).
Choose from which pre-step to extract the data

3. Use JSONPath for Precision(optional):

  • If extracting from a response body, use JSONPath expressions to pinpoint specific data (e.g., extracting a specific ID value).
Write JasonPath expressions to extract data

4. Process Data if Needed(optional):

  • Add processing functions to encrypt, decrypt, or convert data as required.
Add aditional processing function to encrypt the data

For more information concerning setting up Dynamic Values at Apidog, please visit: Transfer Variabiles In Test Case.

Practical Use Case: Using Dynamic Values for Data Passing in API Test Orchestration

Imagine you're testing an online API for a pet store. One automated test task is to confirm that a new pet can be successfully added and its information queried. This involves two steps:

Add New Pet:

  • Send a request to register a new pet.
  • Capture the response, including the new pet's ID.

Query Pet Information:

  • Use the captured pet ID to query the pet's information.

API Test Orchestration without Dynamic Values:

  • Manually copy the pet ID after adding the pet.
  • Paste the ID into the query request.

API Test Orchestration with Dynamic Values:

  • Add a pet -> Capture the pet ID -> Automatically pass the pet ID in a specific step -> Send the request.

This streamlined process requires no manual intervention, significantly enhancing efficiency and reducing errors.

Step-by-Step Implementation in Apifox

Step 1: Extract Parameters

In the "Add a new pet" step, the response structure might look like this:

{
    "code": 0,
    "data": {
        "id": 1,
        "name": "Golden Retriever",
        "photoUrls": ["http://dummyimage.com/336x280"],
        "status": "sold"
        // Other information...
    }
}

Locate the id value within the data object.

Step 2: Reference Dynamic Values

In the "Query pet information" step:

1. Enter the test step details page by clicking on the step.

Click the test step to enter the step customization page

2. Click the "magic wand" icon and select "Retrieve Pre-step Data".

3. Choose the response body as the extraction source.

4. Use a JSONPath expression (e.g., data.id) to extract the pet ID.

5. Click "Insert" to reference this value in the downstream request.

Write a JSONPath expression to extract data from pre-step

Step 3: Verify Parameter Passing

Run the automated test scenario and check the Test Report. Verify that the pet ID from the "Add a New Pet" step is correctly used in the "Query Pet Information" step.

Check API auto-testing result at Apidog

If an error occurs, debug the step by checking the JSONPath expression and the dynamic value setup.

Conclusion

Test orchestration is a cornerstone of software development, ensuring robust and reliable applications. By leveraging Apidog's dynamic values, teams can seamlessly manage data dependencies, adapt to real-time data changes, scale effectively, and maintain accuracy across extensive test suites. This automation not only accelerates the testing cycle but also enhances overall software quality, enabling faster releases.

Incorporating dynamic values into your test orchestration process simplifies complex tasks, allowing for more efficient and reliable testing. This innovative approach transforms cumbersome manual operations into automated, error-free procedures, ultimately optimizing your testing workflow and contributing to the continuous improvement of your software products.

Join Apidog's Newsletter

Subscribe to stay updated and receive the latest viewpoints anytime.