Rust Cargo Test configuration
The allure-cargotest integration is configured through environment variables.
ALLURE_RESULTS_DIR
Overrides the default directory where #[allure_test] writes Allure results.
When unset, allure-cargotest uses target/allure-results.
ALLURE_RESULTS_DIR=./allure-results cargo testALLURE_HOST_NAME
Overrides the host label that allure-cargotest adds automatically.
If this variable is not set, the integration tries to detect the host name from the current machine.
ALLURE_HOST_NAME=ci-linux-01 cargo testALLURE_THREAD_NAME
Overrides the thread label that allure-cargotest adds automatically.
If this variable is not set, the integration uses the current thread name or thread ID.
ALLURE_THREAD_NAME=worker-1 cargo testALLURE_LABEL_*
Adds global labels to every test result.
Any environment variable whose name starts with ALLURE_LABEL_ becomes an Allure label. For example:
ALLURE_LABEL_epic="Web interface" \
ALLURE_LABEL_owner="QA Team" \
cargo testThis applies the epic and owner labels to every test in the run.
allure.label.*
Adds global labels using the alternative naming scheme that some CI tools already use.
Any environment variable whose name starts with allure.label. is treated the same way as ALLURE_LABEL_*.
allure.label.layer=e2e cargo testALLURE_TESTPLAN_PATH
Points to a JSON file that defines which tests should run.
The file uses the standard Allure test plan shape:
{
"version": "1.0",
"tests": [{ "selector": "auth::tests::login_works" }]
}Run the tests with:
ALLURE_TESTPLAN_PATH=./testplan.json cargo testEntries with selector match the full Rust test name, including its module path, and work with #[allure_test].
WARNING
Entries with id are intended to match tests that expose an explicit Allure ID (for example via #[allure_test(id = "AUTH-1")]), but #[allure_test] does not currently forward its id into test-plan matching, so id entries have no effect on macro-based tests — use selector entries for them instead. id matching does work for integrations that call CargoTestReporter::run_test_with_metadata directly with an explicit allure_id.
If ALLURE_TESTPLAN_PATH is unset, the file does not exist, or the JSON is malformed, allure-cargotest skips filtering and runs the tests normally.
ALLURE_LOG_ASSERTS
Controls whether assert!, assert_eq!, assert_ne!, debug_assert!, debug_assert_eq!, and debug_assert_ne! calls inside #[allure_test] and #[step] function bodies are logged as Allure steps.
Assertion logging is enabled by default. Set it to false to disable it for a run, overriding any package-level setting:
ALLURE_LOG_ASSERTS=false cargo testYou can also disable assertion logging for a whole package with Cargo metadata instead of an environment variable — see log_asserts below.
Configure labels in Cargo.toml
Use Cargo package metadata to add labels for local and CI runs without environment variables. A package is the Cargo package defined by the relevant Cargo.toml.
Add labels for all tests in a package
Add labels under [package.metadata.allure.labels]:
[package.metadata.allure.labels]
a = "a-value"
b = ["b-value1", "b-value2"]This adds a=a-value, b=b-value1, and b=b-value2 to every #[allure_test] in the package. String array values add the same label multiple times.
You can also disable assertion logging for the whole package here:
[package.metadata.allure]
log_asserts = falseAdd labels for only some Rust modules
Add one [[package.metadata.allure.modules]] entry per Rust module path. The module value matches the current Rust module_path!() exactly, or any module below it.
[[package.metadata.allure.modules]]
module = "org::example"
labels = { a = "a-value", b = ["b-value1", "b-value2"] }This applies to tests whose module path is org::example, org::example::api, org::example::api::v1, and so on.
For integration tests in tests/api.rs, the test file is its own crate, so module paths usually start with the file stem:
[[package.metadata.allure.modules]]
module = "api::org::example"
labels = { a = "a-value" }Add labels for only test files
Add one [[package.metadata.allure.modules]] entry per file and use path. The path is relative to the package root and uses the same element-wise file path that appears in titlePath.
[[package.metadata.allure.modules]]
path = "tests/payments.rs"
labels = { a = "a-value", b = ["b-value1", "b-value2"] }This applies to every #[allure_test] in tests/payments.rs. You can also match a source file or a directory:
[[package.metadata.allure.modules]]
path = "src/payments.rs"
labels = { component = "payments" }
[[package.metadata.allure.modules]]
path = "tests/api/"
labels = { layer = "api" }The directory form (a path ending in /) matches every test file whose relative path starts with that directory.
Automatic labels added by allure-cargotest
When you use #[allure_test] or CargoTestReporter, allure-cargotest adds a few labels automatically:
language = rustframework = cargo-testhostthread
It also derives suite labels from the Rust module path:
- a single module segment becomes
suite, - two segments become
parentSuiteandsuite, - three or more segments become
parentSuite,suite, andsubSuite.
Explicit calls to allure.parent_suite(...), allure.suite(...), or allure.sub_suite(...) override the automatically derived labels with the same name.