Request Chaining & Delays
This example demonstrates how to chain HTTP requests and use delays in your test suites. It uses our hosted test server at tryme.rocketship.sh
to show real-world API testing scenarios.
Test Specification
name: "Request Chaining & Delays Example"
description: "A test suite demonstrating request chaining and delays with the test server"
version: "v1.0.0"
tests:
- name: "User Management Flow"
steps:
- name: "Create first user"
plugin: "http"
config:
method: "POST"
url: "https://tryme.rocketship.sh/users"
body: |
{
"name": "John Doe",
"email": "john@example.com",
"role": "admin"
}
assertions:
- type: "status_code"
expected: 200
- type: "json_path"
path: ".name"
expected: "John Doe"
save:
- json_path: ".id"
as: "first_user_id"
- json_path: ".email"
as: "first_user_email"
- name: "Wait for system processing"
plugin: "delay"
config:
duration: "1s"
- name: "Create second user"
plugin: "http"
config:
method: "POST"
url: "https://tryme.rocketship.sh/users"
body: |
{
"name": "Jane Smith",
"email": "jane@example.com",
"role": "user"
}
assertions:
- type: "status_code"
expected: 200
save:
- json_path: ".id"
as: "second_user_id"
- name: "Short delay for consistency"
plugin: "delay"
config:
duration: "500ms"
- name: "List all users"
plugin: "http"
config:
method: "GET"
url: "https://tryme.rocketship.sh/users"
assertions:
- type: "status_code"
expected: 200
- type: "json_path"
path: ".users_0.name"
expected: "John Doe"
- type: "json_path"
path: ".users_1.name"
expected: "Jane Smith"
Key Features Demonstrated
Request Chaining:
- Creating multiple users
- Saving response values for later use
- Using saved values in subsequent requests
- Verifying changes across requests
Delays:
- Using delays between operations
- Different delay durations (1s, 500ms)
- Strategic placement for system consistency
Assertions:
- Status code validation
- JSON response validation using JSONPath
- Response content validation
Running the Example
Run the test suite:
Understanding the Flow
The example demonstrates a complete user management workflow:
- Create first user and save their ID and email
- Wait for 1 second to simulate system processing
- Create second user and save their ID
- Add a short 500ms delay for system consistency
- Get all users and verify both exist
Each step builds on the previous ones, showing how to:
- Chain requests together
- Save and use response data
- Verify state changes
- Handle different HTTP methods
- Work with multiple resources
- Use strategic delays for system consistency
The delays in this example are for demonstration purposes. In real-world scenarios, you might use delays when:
- Waiting for asynchronous operations to complete
- Ensuring system consistency in distributed systems
- Rate limiting your API requests
- Testing timeout scenarios