pub trait SoftPanic {
// Required method
fn soft_panic(&self);
}Expand description
Turns assertions into “soft assertions”.
See method soft_panic() for details and how to
use it.
Required Methods§
Sourcefn soft_panic(&self)
fn soft_panic(&self)
Turns assertions into “soft assertions”.
It executes all specified assertions on a Spec and if at least one
assertion fails, it panics. The panic message contains the messages of
all assertions that have failed.
This method is only available on Specs with the
CollectFailures-FailingStrategy. That is any Spec contructed
by the macros verify_that! and verify_that_code! or by the
functions verify_that() and verify_that_code().
On a Spec with the PanicOnFail-FailingStrategy it would not
work as the very first failing assertion panics immediately, and later
assertions never get executed.
§Examples
Running the following two assertions in “soft” mode:
use asserting::prelude::*;
verify_that!("the answer to all important questions is 42")
.contains("unimportant")
.has_at_most_length(41)
.soft_panic();executes both assertions and prints the messages of both failing assertions in the panic message:
expected subject to contain "unimportant"
but was: "the answer to all important questions is 42"
expected: "unimportant"
expected subject to have at most a length of 41
but was: 43
expected: <= 41To highlight differences in failure messages of soft assertions use
the with_configured_diff_format() method, like so:
use asserting::prelude::*;
verify_that!("the answer to all important questions is 42")
.with_configured_diff_format()
.contains("important")
.has_at_most_length(43)
.soft_panic();Implementors§
impl<S> SoftPanic for RecursiveComparison<'_, S, CollectFailures>
recursive only.