pub struct Runner {
pub configuration: Configuration,
/* private fields */
}
Expand description
Runner for executing a test suite’s examples.
Fields§
§configuration: Configuration
Implementations§
Source§impl Runner
impl Runner
Sourcepub fn new(
configuration: Configuration,
observers: Vec<Arc<dyn RunnerObserver>>,
) -> Runner
pub fn new( configuration: Configuration, observers: Vec<Arc<dyn RunnerObserver>>, ) -> Runner
Examples found in repository?
examples/multi.rs (line 12)
9pub fn main() {
10 let logger = Arc::new(rspec::Logger::new(io::stdout()));
11 let configuration = rspec::ConfigurationBuilder::default().build().unwrap();
12 let runner = rspec::Runner::new(configuration, vec![logger]);
13
14 // A test suite using the `suite`, `context`, `example` syntax family:
15 runner.run(&rspec::suite("an value of ten", 10, |ctx| {
16 ctx.context("adding 5 to it", |ctx| {
17 ctx.example("results in fifteen", |num| {
18 assert_eq!(*num, 15);
19 });
20 });
21 }));
22
23 // A test suite using the `describe`, `specify`, `it` syntax family:
24 runner.run(&rspec::describe("an value of ten", 10, |ctx| {
25 ctx.specify("adding 5 to it", |ctx| {
26 ctx.it("results in fifteen", |num| {
27 assert_eq!(*num, 15);
28 });
29 });
30 }));
31
32 // A test suite using the `given`, `when`, `then` syntax family:
33 runner.run(&rspec::given("an value of ten", 10, |ctx| {
34 ctx.when("adding 5 to it", |ctx| {
35 ctx.then("results in fifteen", |num| {
36 assert_eq!(*num, 15);
37 });
38 });
39 }));
40}
Source§impl Runner
impl Runner
Sourcepub fn run<T>(&self, suite: &Suite<T>) -> SuiteReport
pub fn run<T>(&self, suite: &Suite<T>) -> SuiteReport
Examples found in repository?
examples/multi.rs (lines 15-21)
9pub fn main() {
10 let logger = Arc::new(rspec::Logger::new(io::stdout()));
11 let configuration = rspec::ConfigurationBuilder::default().build().unwrap();
12 let runner = rspec::Runner::new(configuration, vec![logger]);
13
14 // A test suite using the `suite`, `context`, `example` syntax family:
15 runner.run(&rspec::suite("an value of ten", 10, |ctx| {
16 ctx.context("adding 5 to it", |ctx| {
17 ctx.example("results in fifteen", |num| {
18 assert_eq!(*num, 15);
19 });
20 });
21 }));
22
23 // A test suite using the `describe`, `specify`, `it` syntax family:
24 runner.run(&rspec::describe("an value of ten", 10, |ctx| {
25 ctx.specify("adding 5 to it", |ctx| {
26 ctx.it("results in fifteen", |num| {
27 assert_eq!(*num, 15);
28 });
29 });
30 }));
31
32 // A test suite using the `given`, `when`, `then` syntax family:
33 runner.run(&rspec::given("an value of ten", 10, |ctx| {
34 ctx.when("adding 5 to it", |ctx| {
35 ctx.then("results in fifteen", |num| {
36 assert_eq!(*num, 15);
37 });
38 });
39 }));
40}
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Runner
impl !RefUnwindSafe for Runner
impl Send for Runner
impl Sync for Runner
impl Unpin for Runner
impl !UnwindSafe for Runner
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