pub struct Expectation<T> { /* private fields */ }Implementations§
Source§impl<T> Expectation<T>
impl<T> Expectation<T>
Source§impl<T> Expectation<T>
impl<T> Expectation<T>
Sourcepub fn to_be(self, expected: T)
pub fn to_be(self, expected: T)
Examples found in repository?
examples/example_smoke.rs (line 10)
5fn main() {
6 let tests = collect_tests(|| {
7 describe!("math", {
8 test!("adds two numbers", |ctx| {
9 ctx.stdout("ok\n");
10 expect(2 + 3).to_be(5);
11 });
12
13 test!("handles negatives", id = "math/handles-negatives", |ctx| {
14 assert!(ctx.observe().metric("wall_time_ns", 42.0));
15 expect(-2 + 1).to_be(-1);
16 });
17 });
18 })
19 .expect("collection should validate");
20
21 for test in &tests {
22 let outcome = run_test(test);
23 println!("{} => {}", test.canonical_name(), outcome.exit);
24 }
25}pub fn to_equal(self, expected: T)
Source§impl<T> Expectation<T>
impl<T> Expectation<T>
Sourcepub fn to_be_truthy(self)
pub fn to_be_truthy(self)
Examples found in repository?
examples/host_example.rs (line 10)
5fn main() {
6 let tests = collect_tests(|| {
7 describe!("pkg", {
8 test!("smoke test", id = "pkg::smoke", |ctx| {
9 ctx.stdout("ok\n");
10 expect(true).to_be_truthy();
11 });
12
13 test!("failing test", id = "pkg::fail", |ctx| {
14 ctx.stderr("failure\n");
15 ctx.set_exit(1);
16 });
17 });
18 })
19 .expect("collection should validate");
20
21 let exit_code = match observer_host_main("rust", &tests) {
22 Ok(()) => 0,
23 Err(error) => {
24 eprintln!("{error}");
25 2
26 }
27 };
28 std::process::exit(exit_code);
29}More examples
examples/host_embed_example.rs (line 14)
9fn main() {
10 let tests = collect_tests(|| {
11 describe!("pkg", {
12 test!("embedded smoke test", id = "pkg::embedded-smoke", |ctx| {
13 ctx.stdout("ok\n");
14 expect(true).to_be_truthy();
15 });
16 });
17 })
18 .expect("collection should validate");
19
20 let args = std::env::args().collect::<Vec<_>>();
21 if args.get(1).map(String::as_str) == Some("observe") {
22 let exit_code = match observer_host_dispatch_embedded("rust", "observe", &tests, args) {
23 Ok(()) => 0,
24 Err(error) => {
25 eprintln!("{error}");
26 2
27 }
28 };
29 std::process::exit(exit_code);
30 }
31
32 app_main(&args);
33}pub fn to_be_falsy(self)
Source§impl<T> Expectation<T>
impl<T> Expectation<T>
pub fn to_contain<S>(self, expected: S)
pub fn to_match<P>(self, pattern: P)where
P: StrPattern,
Auto Trait Implementations§
impl<T> Freeze for Expectation<T>where
T: Freeze,
impl<T> RefUnwindSafe for Expectation<T>where
T: RefUnwindSafe,
impl<T> Send for Expectation<T>where
T: Send,
impl<T> Sync for Expectation<T>where
T: Sync,
impl<T> Unpin for Expectation<T>where
T: Unpin,
impl<T> UnsafeUnpin for Expectation<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Expectation<T>where
T: UnwindSafe,
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