Test Options
Options control how k6 executes your test, including the number of VUs, test duration, thresholds, and more. Options can be set in multiple ways with a clear precedence order.Setting Options
Options can be defined in three ways (in order of precedence):- Command-line flags - Highest priority
- Environment variables
- Script options - Lowest priority
Basic Execution Options
Virtual Users and Duration
The simplest way to configure a test:Iterations
Run a specific number of iterations instead of time-based:With 10 VUs and 100 iterations, each VU will execute approximately 10 iterations.
Stages (Ramping)
Gradually ramp VUs up and down:Thresholds
Thresholds define pass/fail criteria for your test. If a threshold fails, k6 exits with a non-zero status code.Threshold Expressions
Common threshold expressions:HTTP Options
Request Limits
TLS/SSL Configuration
User Agent and Headers
Timeouts
Tags
Apply tags to all metrics in the test:System Tags
Control which system tags are included with metrics:DNS Configuration
Hosts Override
Map hostnames to IPs:Blocked Hostnames
Prevent requests to specific hosts:Blacklist IPs
Block requests to specific IP ranges:Discard Response Bodies
Save memory by discarding response bodies:Summary Configuration
Paused Mode
Start test in paused state:Minimum Iteration Duration
Enforce a minimum time per iteration:Cookie Behavior
Complete Example
Here’s a comprehensive example combining multiple options:Options Reference Table
Next Steps
- Explore Scenarios for advanced execution control
- Learn about Tags and Groups for organizing metrics
- Understand Test Structure fundamentals