Struct subplotlib::prelude::Scenario
source · 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
impl Scenario
sourcepub fn new(title: &str, location: &'static str) -> Self
pub fn new(title: &str, location: &'static str) -> Self
Create a new scenario with the given title
sourcepub fn add_step(&mut self, step: ScenarioStep, cleanup: Option<ScenarioStep>)
pub fn add_step(&mut self, step: ScenarioStep, cleanup: Option<ScenarioStep>)
Add a scenario step, with optional cleanup step function.
sourcepub fn register_context_type<C>(&self)where
C: ContextElement,
pub fn register_context_type<C>(&self)where C: ContextElement,
Register a type with the scenario contexts
sourcepub fn run(self) -> Result<(), StepError>
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§
impl !RefUnwindSafe for Scenario
impl !Send for Scenario
impl !Sync for Scenario
impl Unpin for Scenario
impl !UnwindSafe for Scenario
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more