pub struct Scenario { /* private fields */ }
Expand description

The embodiment of a subplot scenario

Scenario objects are built up by the generated test functions and then run to completion. In rare cases they may be built up and cached for reuse for example if a scenario is a subroutine.

Scenarios are built from steps in sequence, and then can be run.


let mut scenario = Scenario::new("example scenario", "unknown");

let run_step = subplotlib::steplibrary::runcmd::run::Builder::default()
    .argv0("true")
    .args("")
    .build("when I run true".to_string(), "unknown");
scenario.add_step(run_step, None);

Implementations§

source§

impl Scenario

source

pub fn new(title: &str, location: &'static str) -> Self

Create a new scenario with the given title

source

pub fn title(&self) -> &str

Retrieve the scenario title

source

pub fn add_step(&mut self, step: ScenarioStep, cleanup: Option<ScenarioStep>)

Add a scenario step, with optional cleanup step function.

source

pub fn register_context_type<C>(&self)where C: ContextElement,

Register a type with the scenario contexts

source

pub fn run(self) -> Result<(), StepError>

Run the scenario to completion.

Running the scenario to completion requires running each step in turn. This will return the first encountered error, or unit if the scenario runs cleanly.

Panics

If any of the cleanup functions error, this will immediately panic.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.