File-Level Parameters
The parameters section provides a way to override configuration settings at the scenario file level. This allows you to customize behavior for specific scenario files without changing the global configuration.
Syntax
Place the parameters: block at the top of your scenario file, before any
scenarios or fragments:
parameters:
baseUrl: "http://localhost:8080"
timeout: 60
shareVariablesAcrossScenarios: true
scenario: My test scenario
when I call the API
call ^listPets
Supported Parameters
Configuration Overrides
Parameter |
Description |
Example Value |
|---|---|---|
|
Override the base URL for API requests |
|
|
Request timeout in seconds |
|
|
Environment name for reporting |
|
|
Fail on schema validation warnings |
|
|
Follow HTTP redirects |
|
|
Log HTTP requests |
|
|
Log HTTP responses |
|
|
Share extracted variables across scenarios |
|
Header Overrides
Use the header. prefix to add or override default headers:
parameters:
header.Authorization: "Bearer test-token"
header.X-Api-Key: "my-api-key"
header.Accept: "application/json"
Auto-Assertion Overrides
Control automatic assertion generation:
Parameter |
Description |
|---|---|
|
Enable/disable all auto-assertions |
|
Auto-assert correct status code |
|
Auto-assert Content-Type header |
|
Auto-assert response matches schema |
Example:
parameters:
autoAssertions.enabled: false
Use Cases
Environment-Specific Settings
Configure different base URLs or authentication for different environments:
# production-tests.scenario
parameters:
baseUrl: "https://api.production.example.com"
header.Authorization: "Bearer prod-readonly-token"
logRequests: false
scenario: Production health check
when I check the API health
call ^healthCheck
then the API is healthy
assert status 200
Cross-Scenario Variable Sharing
Enable variable sharing for integration test flows:
# crud-workflow.scenario
parameters:
shareVariablesAcrossScenarios: true
logRequests: true
scenario: Create a resource
when I create a pet
call ^createPet
body: {"name": "Fluffy", "tag": "dog"}
extract $.id => petId
scenario: Verify the resource
when I retrieve the pet
call ^getPetById
petId: {{petId}}
then the pet exists
assert $.name equals "Fluffy"
scenario: Clean up
when I delete the pet
call ^deletePet
petId: {{petId}}
then deletion succeeded
assert status 200
Testing with Debug Logging
Enable verbose logging for troubleshooting:
parameters:
logRequests: true
logResponses: true
timeout: 120
scenario: Debug complex flow
when I perform complex operation
call ^complexOperation
body: {"debug": true}
Programmatic Usage
When using the ScenarioLoader programmatically, you can access parameters
through the ScenarioFileContent class:
val loader = ScenarioLoader()
val content = loader.loadFileContent(path)
// Access scenarios
val scenarios = content.scenarios
// Access parameters
val parameters = content.parameters
val baseUrl = parameters["baseUrl"] as? String
val timeout = parameters["timeout"] as? Long
To run scenarios with file-level parameters, use the runWithParameters method:
val runner = ScenarioRunner(specRegistry, configuration, pluginRegistry)
// Run with file-level parameter overrides
val result = runner.runWithParameters(content.scenarios, content.parameters)
// Or apply parameters to configuration manually
val modifiedConfig = configuration.withParameters(content.parameters)
// Execute with modifiedConfig...
JUnit Engine Integration
File-level parameters work with both JUnit tests and standalone ScenarioRunner.
When using JUnit tests, parameters in the .scenario file are applied and take
precedence over the bindings configuration for that specific file.
For JUnit tests, you can also configure settings in your bindings class:
class MyBindings : BerryCrushBindings() {
override fun configure(configuration: Configuration) {
// These can be overridden by file-level parameters
configuration.logRequests = true
}
}
Parameters defined in the scenario file will override the bindings configuration for the scenarios in that specific file. This allows you to have default settings in your bindings while customizing behavior for specific test files.
Configuration Priority
Parameters are applied in the following order (later values override earlier):
Default
ConfigurationvaluesProgrammatic configuration changes
File-level
parameters:section (highest priority for that file)
Notes
Parameters only affect scenarios in the same file
Empty parameter values are ignored
Unknown parameter names are silently ignored
Boolean values can be
true/falseor"true"/"false"stringsTimeout values must be integers (seconds)
See Also
Standalone Runner - Running scenarios without JUnit
Kotlin DSL - Programmatic scenario configuration