| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Official Allure Framework libraries for generating Allure Report results in Rust.
allure-rust is the Rust implementation of the Allure Framework. It provides primitives to build Allure-compatible results and a ready-to-use integration for cargo test.
This workspace currently includes:
For regular Rust tests with automatic lifecycle wiring:
cargo add allure-cargotest --devFor building your own integration/framework adapter:
cargo add allure-rust-commonsBy default, results are written to target/allure-results. You can override it with:
ALLURE_RESULTS_DIR=./allure-results cargo testAfter tests finish and *-result.json files are present in your results directory, use the Allure 3 CLI to generate and open the report:
allure generate ./target/allure-results --output ./target/allure-report --clean
allure open ./target/allure-reportIf you installed Allure 3 through Node tooling, use the equivalent npx command provided by your installation method.
Implemented runtime facade APIs include:
use allure_cargotest::{allure_test, step};
use allure_rust_commons::{feature, log_step, parameter, stage};
#[allure_test]
#[test]
fn test_with_allure() {
feature("Authentication");
parameter("browser", "firefox");
stage("open login page");
open_login_page();
log_step("login page opened");
}
#[step]
fn open_login_page() {
// your step implementation
}The #[allure_test] attribute initializes a reporter automatically (using ALLURE_RESULTS_DIR or target/allure-results) and wraps the test lifecycle. It supports ordinary () tests and explicit return types that implement std::process::Termination, including Rust-style Result<(), E>, ExitCode, and custom termination types. Returned Err values and unsuccessful ExitCode values are written to Allure before Cargo interprets the result.
For environments where attribute macros are not allowed, use the macro-free runtime from commons:
use allure_rust_commons as allure;
#[test]
fn test_with_allure_runtime() {
allure::test(|| {
allure::feature("Authentication");
allure::stage("open login page");
allure::log_step("open login page");
});
}Async tests can compose #[allure_test] with a runtime-specific test macro such as #[tokio::test]. Add and configure Tokio in your test crate; allure-cargotest does not depend on Tokio.
use allure_cargotest::allure_test;
#[allure_test]
#[tokio::test]
async fn async_test_with_allure() {
allure.feature("Async API");
tokio::task::yield_now().await;
allure.parameter("runtime", "tokio");
}Allure context is available in the root async test body and awaited helpers. Implicit propagation into independently spawned tasks is not guaranteed. Async tests may also return Result<(), E>, ExitCode, custom Termination, or impl Termination values when the runtime-specific test macro supports them.
#[allure_test] also derives synthetic suite labels from the Rust module path when a full name is available. A single module segment becomes suite; with two or more segments, the first becomes parentSuite, the second becomes suite, and any remaining module segments are joined into subSuite. If your test calls allure.parent_suite(...), allure.suite(...), or allure.sub_suite(...), those explicit labels override the synthetic defaults for the same label name.
allure-rust-commons is the foundation layer that other integrations build on. It exports these main building blocks:
This separation lets you choose either:
To integrate Allure with another Rust test runner or framework:
Minimal sketch:
use allure_rust_commons::{AllureRuntime, FileSystemResultsWriter, Status};
let writer = FileSystemResultsWriter::new("target/allure-results")?;
let runtime = AllureRuntime::new(writer);
let lifecycle = runtime.lifecycle();
lifecycle.start_test_case(
allure_rust_commons::StartTestCaseParams::new("my test").with_full_name("suite::my test")
);
// ... update metadata, steps, and attachments during execution ...
lifecycle.stop_test_case(Status::Passed, None);For convenience APIs, wrap the lifecycle in AllureFacade::with_lifecycle(...) and expose framework-specific helpers similar to #[allure_test] from allure-cargotest. Adapters can also call push_current_allure(&facade) while a test runs so users can import thread-bound functions directly from allure-rust-commons.
Rust requires attribute procedural macros to be compiled from a proc-macro crate. A proc-macro crate cannot serve as a regular runtime library crate at the same time, so runtime/reporter APIs stay in allure-cargotest and macro implementation lives in allure-test-macros.
From a user perspective this remains a single entrypoint because allure-cargotest re-exports #[allure_test], #[step], and #[log_asserts].
| Back | FazBrowse Home | New Git URL |