Skip to main content

example_smoke/
example_smoke.rs

1// SPDX-License-Identifier: MIT
2
3use observer_rust_lib::{collect_tests, describe, expect, run_test, test};
4
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}