pub fn step<F, R>(name: impl Into<String>, body: F) -> Rwhere
F: FnOnce() -> R,Expand description
Executes a step with the given name and body.
Steps are the building blocks of test reports. They provide a hierarchical view of what the test is doing and can be nested.
ยงExample
use allure_core::runtime::{with_test_context, step};
with_test_context(|| {
step("Login to application", || {
step("Enter credentials", || {
// Enter username and password
});
step("Click submit", || {
// Click the submit button
});
});
});Steps can also return values:
use allure_core::runtime::{with_test_context, step};
with_test_context(|| {
let result = step("Calculate result", || {
2 + 2
});
assert_eq!(result, 4);
});