How to: Pass environment variables to your tests#
Running your tests may require different test context based on your environment. You may want to have different configurations options which you pass as environment variables, or you write them in a configuration file.
Setting environment variable:
export TESTS_CONF_FILE="conf.production.json"
altwalker online tests -m models/models.json "random(vertex_coverage(30))"
set TESTS_CONF_FILE="conf.production.json"
altwalker online tests -m models/models.json "random(vertex_coverage(30))"
Accessing environment variable in your tests:
config_file = os.environ.get("TESTS_CONF_FILE", "conf.development.json")
var configFile = Environment.GetEnvironmentVariable("TESTS_CONF_FILE") ?? "conf.development.json";