pub trait Driver {
// Required methods
fn set(&mut self, var: &Variable, value: &Value) -> Result<(), String>;
fn perform(&mut self, event: &Event) -> Result<(), String>;
fn observe(&mut self, var: &Variable) -> Result<Value, String>;
// Provided methods
fn needs(&self) -> Vec<String> { ... }
fn fresh(&self) -> Vec<String> { ... }
fn reset(&mut self) -> Result<(), String> { ... }
fn arrange(&mut self, var: &Variable, value: &Value) -> Result<(), String> { ... }
fn can_arrange(&self, var: &Variable, value: &Value) -> bool { ... }
fn settle(&mut self) { ... }
fn advance(&mut self) -> Progress { ... }
fn screenshot(&mut self) -> Result<Option<Screenshot>, String> { ... }
fn supports(&self, need: Need<'_>) -> bool { ... }
}Expand description
Drives the system under test in the vocabulary’s terms.
Calls may block. A real-time system (a game, a simulation) can let time pass in Driver::advance
and the runner keeps observing until a step’s checks hold or its patience runs out, so
“Then the kettle is heating” means eventually, as it would for a person watching.
Required Methods§
Sourcefn set(&mut self, var: &Variable, value: &Value) -> Result<(), String>
fn set(&mut self, var: &Variable, value: &Value) -> Result<(), String>
Make var hold value as an action (“When the dial is 80 %”).
Provided Methods§
Sourcefn needs(&self) -> Vec<String>
fn needs(&self) -> Vec<String>
The external services this driver needs for its tests (see crate::service): a
controller, a database. The runner starts them before a plan, and when one cannot be had
here the plans are “not supported yet”, with what to do about it.
Sourcefn fresh(&self) -> Vec<String>
fn fresh(&self) -> Vec<String>
The services that must be started afresh before each test (a database the last
test wrote to): a subset of Driver::needs.
Sourcefn reset(&mut self) -> Result<(), String>
fn reset(&mut self) -> Result<(), String>
Put the system in its starting state (what the Background describes), before each test.
Sourcefn arrange(&mut self, var: &Variable, value: &Value) -> Result<(), String>
fn arrange(&mut self, var: &Variable, value: &Value) -> Result<(), String>
Make var hold value before the first step (“Given …”).
Sourcefn can_arrange(&self, var: &Variable, value: &Value) -> bool
fn can_arrange(&self, var: &Variable, value: &Value) -> bool
Can it put var in value to start a test? Driver::supports only knows the state; a
driver that can arrange some of its values and not others (a test account that can’t
be emptied can’t start with no messages) says so here, and the tests that need the rest
are “not supported yet” instead of failing.
Sourcefn settle(&mut self)
fn settle(&mut self)
Let the system settle after an action, before anything is observed: long enough for what should happen to happen, and for what shouldn’t to show. Without it, “Then the kettle is off” could pass in the instant before it switches on.
fn screenshot(&mut self) -> Result<Option<Screenshot>, String>
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".