pub struct TestContext {
pub result: TestResult,
pub step_stack: Vec<StepResult>,
pub writer: AllureWriter,
}Expand description
Test context holding the current test result and step stack.
Fields§
§result: TestResultThe current test result being built.
step_stack: Vec<StepResult>Stack of active steps (for nested steps).
writer: AllureWriterThe writer for this context.
Implementations§
Source§impl TestContext
impl TestContext
Sourcepub fn new(name: impl Into<String>, full_name: impl Into<String>) -> TestContext
pub fn new(name: impl Into<String>, full_name: impl Into<String>) -> TestContext
Creates a new test context.
Sourcepub fn add_label(&mut self, name: impl Into<String>, value: impl Into<String>)
pub fn add_label(&mut self, name: impl Into<String>, value: impl Into<String>)
Adds a label to the current test.
Sourcepub fn add_label_name(&mut self, name: LabelName, value: impl Into<String>)
pub fn add_label_name(&mut self, name: LabelName, value: impl Into<String>)
Adds a label using a reserved name.
Sourcepub fn add_link(
&mut self,
url: impl Into<String>,
name: Option<String>,
link_type: LinkType,
)
pub fn add_link( &mut self, url: impl Into<String>, name: Option<String>, link_type: LinkType, )
Adds a link to the current test.
Sourcepub fn add_parameter(
&mut self,
name: impl Into<String>,
value: impl Into<String>,
)
pub fn add_parameter( &mut self, name: impl Into<String>, value: impl Into<String>, )
Adds a parameter to the current test or step.
Sourcepub fn add_parameter_struct(&mut self, parameter: Parameter)
pub fn add_parameter_struct(&mut self, parameter: Parameter)
Adds a parameter with custom options (hidden/masked/excluded).
Sourcepub fn add_attachment(&mut self, attachment: Attachment)
pub fn add_attachment(&mut self, attachment: Attachment)
Adds an attachment to the current test or step.
Sourcepub fn start_step(&mut self, name: impl Into<String>)
pub fn start_step(&mut self, name: impl Into<String>)
Starts a new step.
Sourcepub fn finish_step(
&mut self,
status: Status,
message: Option<String>,
trace: Option<String>,
)
pub fn finish_step( &mut self, status: Status, message: Option<String>, trace: Option<String>, )
Finishes the current step with the given status.
Sourcepub fn compute_history_id(&mut self)
pub fn compute_history_id(&mut self)
Computes and sets the history ID based on the full name and parameters.
Sourcepub fn finish(
&mut self,
status: Status,
message: Option<String>,
trace: Option<String>,
)
pub fn finish( &mut self, status: Status, message: Option<String>, trace: Option<String>, )
Finishes the test with the given status and writes the result.
Sourcepub fn attach_text(&mut self, name: impl Into<String>, content: impl AsRef<str>)
pub fn attach_text(&mut self, name: impl Into<String>, content: impl AsRef<str>)
Creates a text attachment.
Sourcepub fn attach_json<T>(&mut self, name: impl Into<String>, value: &T)where
T: Serialize,
pub fn attach_json<T>(&mut self, name: impl Into<String>, value: &T)where
T: Serialize,
Creates a JSON attachment.
Sourcepub fn attach_binary(
&mut self,
name: impl Into<String>,
content: &[u8],
content_type: ContentType,
)
pub fn attach_binary( &mut self, name: impl Into<String>, content: &[u8], content_type: ContentType, )
Creates a binary attachment.
Sourcepub fn attach_file(
&mut self,
name: impl Into<String>,
path: impl AsRef<Path>,
content_type: Option<ContentType>,
)
pub fn attach_file( &mut self, name: impl Into<String>, path: impl AsRef<Path>, content_type: Option<ContentType>, )
Attaches a file from the filesystem.