pub struct Story { /* private fields */ }Expand description
A BDD story builder that captures steps and emits a RawTestCase on drop.
Call .pass() before the story goes out of scope to mark the test as passed.
If .pass() is not called, the test case will be recorded with status "fail".
Implementations§
Source§impl Story
impl Story
Set tags on the story (consumes and returns self for chaining at creation).
Sourcepub fn with_tickets(self, tickets: &[&str]) -> Self
pub fn with_tickets(self, tickets: &[&str]) -> Self
Set tickets on the story (consumes and returns self for chaining at creation).
Sourcepub fn with_ticket_url(self, id: &str, url: &str) -> Self
pub fn with_ticket_url(self, id: &str, url: &str) -> Self
Add a ticket with a URL to the story (consumes and returns self for chaining).
Sourcepub fn with_trace_url_template(self, template: &str) -> Self
pub fn with_trace_url_template(self, template: &str) -> Self
Set the URL template for OTel trace links (uses {traceId} placeholder).
Also settable via OTEL_TRACE_URL_TEMPLATE env var.
Sourcepub fn assert_that(&mut self, text: &str) -> &mut Self
pub fn assert_that(&mut self, text: &str) -> &mut Self
Add an Assert step (alias for Then). Uses assert_that because assert! is a macro.
Sourcepub fn with_docs(&mut self, docs: Vec<StepDoc>) -> &mut Self
pub fn with_docs(&mut self, docs: Vec<StepDoc>) -> &mut Self
Attach inline documentation entries to the most recently added step.
Sourcepub fn start_timer(&mut self) -> usize
pub fn start_timer(&mut self) -> usize
Start a high-resolution timer tied to the current step. Returns a token to pass to end_timer().
Sourcepub fn end_timer(&mut self, token: usize)
pub fn end_timer(&mut self, token: usize)
Stop the timer and record duration_ms on the step that was active when start_timer() was called. Double-end is a no-op.
Sourcepub fn fn_step<F, T>(&mut self, keyword: &str, text: &str, body: F) -> Twhere
F: FnOnce() -> T,
pub fn fn_step<F, T>(&mut self, keyword: &str, text: &str, body: F) -> Twhere
F: FnOnce() -> T,
Wrap a closure as a BDD step with automatic timing.
Creates a step marked as wrapped=true, executes the body,
records duration_ms, and re-panics if the body panicked.
Sourcepub fn expect_step<F, T>(&mut self, text: &str, body: F) -> Twhere
F: FnOnce() -> T,
pub fn expect_step<F, T>(&mut self, text: &str, body: F) -> Twhere
F: FnOnce() -> T,
Shorthand for fn_step("Then", text, body).
Sourcepub fn note(&mut self, text: &str) -> &mut Self
pub fn note(&mut self, text: &str) -> &mut Self
Attach a text note to the current step or story.
Sourcepub fn tag(&mut self, names: &[&str]) -> &mut Self
pub fn tag(&mut self, names: &[&str]) -> &mut Self
Attach tag annotations to the current step or story.
Sourcepub fn kv(&mut self, label: &str, value: Value) -> &mut Self
pub fn kv(&mut self, label: &str, value: Value) -> &mut Self
Attach a key-value pair to the current step or story.
Sourcepub fn json(&mut self, label: &str, value: &impl Serialize) -> &mut Self
pub fn json(&mut self, label: &str, value: &impl Serialize) -> &mut Self
Attach a JSON document (serialized as code with lang=json) to the current step or story.
Sourcepub fn code(
&mut self,
label: &str,
content: &str,
lang: Option<&str>,
) -> &mut Self
pub fn code( &mut self, label: &str, content: &str, lang: Option<&str>, ) -> &mut Self
Attach a code block to the current step or story.
Sourcepub fn table(
&mut self,
label: &str,
columns: &[&str],
rows: &[&[&str]],
) -> &mut Self
pub fn table( &mut self, label: &str, columns: &[&str], rows: &[&[&str]], ) -> &mut Self
Attach a table to the current step or story.
Sourcepub fn link(&mut self, label: &str, url: &str) -> &mut Self
pub fn link(&mut self, label: &str, url: &str) -> &mut Self
Attach a link to the current step or story.
Sourcepub fn section(&mut self, title: &str, markdown: &str) -> &mut Self
pub fn section(&mut self, title: &str, markdown: &str) -> &mut Self
Attach a markdown section to the current step or story.
Sourcepub fn mermaid(&mut self, code: &str, title: Option<&str>) -> &mut Self
pub fn mermaid(&mut self, code: &str, title: Option<&str>) -> &mut Self
Attach a mermaid diagram to the current step or story.
Sourcepub fn screenshot(&mut self, path: &str, alt: Option<&str>) -> &mut Self
pub fn screenshot(&mut self, path: &str, alt: Option<&str>) -> &mut Self
Attach a screenshot reference to the current step or story.
Sourcepub fn custom(&mut self, type_name: &str, data: Value) -> &mut Self
pub fn custom(&mut self, type_name: &str, data: Value) -> &mut Self
Attach a custom doc entry to the current step or story.
Sourcepub fn attach(&mut self, name: &str, media_type: &str, path: &str) -> &mut Self
pub fn attach(&mut self, name: &str, media_type: &str, path: &str) -> &mut Self
Attach a file-based attachment to the story.
Sourcepub fn attach_inline(
&mut self,
name: &str,
media_type: &str,
body: &str,
encoding: &str,
) -> &mut Self
pub fn attach_inline( &mut self, name: &str, media_type: &str, body: &str, encoding: &str, ) -> &mut Self
Attach an inline (body-based) attachment to the story.
Sourcepub fn attach_spans(&mut self, spans: Vec<Value>) -> &mut Self
pub fn attach_spans(&mut self, spans: Vec<Value>) -> &mut Self
Attach OTel spans for trace waterfall rendering in HTML reports.