pub fn soft<F>(f: F) -> Result<(), TestError>where
F: FnOnce(&mut SoftAsserter),Expand description
Runs f in a soft-assertion scope.
Inside f, failures recorded on the SoftAsserter do not end the
closure. When f returns, soft returns Ok(()) if nothing was recorded,
or a single TestError collecting every recorded failure.
If f panics, the panic does not swallow what was already recorded:
soft runs f under catch_unwind, prints the
collected soft failures to standard error, and then re-raises the panic so
the test still fails on it.
use test_better_core::TestResult;
use test_better_matchers::{eq, soft};
fn main() -> TestResult {
soft(|s| {
s.check(&2, eq(2));
s.check(&"alice", eq("alice"));
})?;
Ok(())
}