# Parameterizing Tests with Environment Variables
Source: https://www.jetify.com/docs/docs/testpilot/guides/parameterize-tests-environment-variables

Make tests flexible and reusable with environment variables. Run the same tests across staging, development, and production environments.

## Using Environment Variables in Tests[​](#using-environment-variables-in-tests "Direct link to Using Environment Variables in Tests")

You can include environment variables in your test files using the format
`${ENV_VAR_NAME:-default_value}`. Testpilot will automatically expand these variables when running
your tests.

The syntax works as follows:

* `${ENV_VAR_NAME}` - Uses the value of the environment variable
* `${ENV_VAR_NAME:-default_value}` - Uses the value of the environment variable if set, otherwise
  uses the default value

## Example: Parameterizing Host URLs[​](#example-parameterizing-host-urls "Direct link to Example: Parameterizing Host URLs")

A common use case is parameterizing the host URL in your tests. This lets you run the same tests
against different environments without modifying your test files:

```yaml theme={null}
name: "Parameterized URL Test"
context:
  - text: "Test can run against different environments based on the TEST_HOST environment variable"
cases:
  - id: "login-test-001"
    name: "User Login Test"
    description: "Test user login functionality across different environments"
    url: "${TEST_HOST:-https://staging.example.com}/login"
    steps:
      - "Navigate to the login page"
      - "Enter valid username and password"
      - "Click the login button"
      - "Verify successful login"
```

In this example:

* If `TEST_HOST` is set (e.g., `export TEST_HOST=https://dev.example.com`), the test will use that
  value
* If `TEST_HOST` is not set, it will fall back to the default value `https://staging.example.com`

## Running Tests with Different Parameters[​](#running-tests-with-different-parameters "Direct link to Running Tests with Different Parameters")

You can run the same test with different parameter values by changing the environment variables:

```bash theme={null}