Scenario Testing
Create reusable multi-endpoint test flows
Scenarios allow you to create reusable test workflows that execute multiple API endpoints in sequence or parallel. Perfect for testing complete user flows like registration, authentication, and data operations.
Availability
Scenario testing is currently available only in the Go implementation. Support for other languages is planned.
What are Scenarios?
A scenario is a collection of API requests that can be:
- Sequential: Execute one after another
- Parallel: Execute simultaneously (planned feature)
- Dependent: Use data from previous requests
- Reusable: Save and run anytime
- Shareable: Export/import as JSON
Use Cases
1. User Registration Flow
2. E-commerce Purchase Flow
3. CRUD Operations
Creating Scenarios
Via UI
- Navigate to Scenarios in the Bytedocs UI
- Click "New Scenario"
- Add details:
- Name
- Description
- Execution mode
- Add requests:
- Select endpoint
- Configure parameters
- Set up variable extraction
- Save & Execute
Via API
Via JSON Import
Scenario Configuration
Basic Structure
Scenario Config
Request Structure
Variable Extraction
Extract values from responses to use in subsequent requests:
JSONPath Syntax
Using Extracted Variables
Use {{variable_name}} syntax in subsequent requests:
Assertions
Validate response data:
Assertion Types
| Type | Description | Example |
|---|---|---|
status | HTTP status code | {"type": "status", "expected": 200} |
json_path | JSONPath expression | {"type": "json_path", "path": "$.id"} |
header | Response header | {"type": "header", "name": "Content-Type"} |
response_time | Response duration | {"type": "response_time", "operator": "less_than", "expected": 500} |
body_contains | Body contains text | {"type": "body_contains", "expected": "success"} |
Operators
equalsnot_equalsgreater_thanless_thancontainsnot_containsexistsnot_existsmatches(regex)
Execution Modes
Sequential (Default)
Requests execute one after another:
Use when:
- Requests depend on each other
- Order matters
- Need to extract data between requests
Parallel (Coming Soon)
Requests execute simultaneously:
Use when:
- Requests are independent
- Want faster execution
- Testing concurrent load
Error Handling
Continue on Failure
true: Continue executing remaining requestsfalse: Stop on first failure (default)
Timeout
Set maximum execution time in seconds.
Authentication
Bearer Token
Basic Auth
API Key
Dynamic (from previous request)
Environment Variables
Set reusable variables:
API Endpoints
List Scenarios
Get Scenario
Create Scenario
Update Scenario
Delete Scenario
Execute Scenario
Response:
Export Scenarios
Returns all scenarios as JSON.
Import Scenarios
Best Practices
1. Descriptive Names
2. Meaningful Request Names
3. Use Assertions
4. Extract Reusable Data
5. Handle Errors Gracefully
Troubleshooting
Scenario Execution Fails
Check:
- Base URL is correct
- Authentication is valid
- Variable extraction paths are correct
- Request bodies are valid JSON
Variables Not Resolved
Ensure:
- Variable was extracted in previous request
- JSONPath expression is correct
- Response actually contains the data
- Using correct syntax:
{{variable_name}}
Timeout Errors
Solutions:
- Increase timeout in config
- Check endpoint performance
- Verify network connectivity
- Run requests individually to identify slow endpoint
What's Next?
- Performance Testing - Load test with K6 (Laravel)
- Interactive Testing - Test individual endpoints
- AI Assistant - Get help from AI