Table of Contents
Table of Contents
Further Reading
What Does Variable Mean?
A variable is a symbolic name or placeholder that stores values which may change during test execution. Variables define inputs, configurations, or parameters without hardcoding data.
That makes tests more dynamic and reusable across environments and scenarios.
Hardcoded Values vs. Variables
Common Types of Variables in Testing
- Environment variables: values injected into the runtime, such as base URLs or region names
- Configuration parameters: inputs like timeouts, user counts, or feature flags
- Secrets: sensitive values such as API keys and passwords, stored securely
- Test data variables: datasets or IDs that change between scenarios
Why Variables Matter
Variables make testing workflows adaptable and maintainable. Teams parameterize values like URLs, credentials, or resource names instead of duplicating tests. This helps teams:
- Reuse test definitions across multiple environments
- Reduce duplication and maintenance overhead
- Control test behavior dynamically at runtime
- Scale consistently across automated testing workflows
Variables are fundamental to configuration-as-code and infrastructure-agnostic testing.
How Variables Work with Testkube
- Workflow configuration: Variables can be defined directly in a test workflow to customize execution.
- Environment variables: Testkube injects environment variables into test pods for dynamic runtime values.
- Secrets and ConfigMaps: Sensitive or structured values are stored and managed as Kubernetes resources.
- Workflow parameterization: The same workflow adapts across clusters, namespaces, or pipelines.
- CLI and API support: Values can be passed through the Testkube CLI or API when triggering runs.
Real-World Example
A B2B SaaS team runs the same k6 load test against staging and a production mirror. Each environment has a different URL, user count, and API key.
- Define variables: the workflow declares BASE_URL and VIRTUAL_USERS.
- Store secrets: the API key lives in a Kubernetes Secret.
- Pass values: each CI pipeline supplies its own values when triggering the run.
One workflow now covers both environments, and the API key never appears in code.
Best Practices for Using Variables
- Never hardcode secrets: Store credentials in Secrets or a secrets manager.
- Use clear names: Names like BASE_URL explain themselves to other teams.
- Set sensible defaults: Defaults make tests easy to run locally.
- Document required variables: List inputs so others can reuse the test quickly.
- Validate inputs early: Fail fast when a required value is missing.



