pub type Result<T> = Result<T, TestAssertionFailure>;
Expand description
A Result
whose Err
variant indicates a test failure.
The assertions verify_that!
,
verify_pred!
, and fail!
evaluate
to Result<()>
. A test function may return Result<()>
in combination with
those macros to abort immediately on assertion failure.
This can be used with subroutines which may cause the test to fatally fail and which return some value needed by the caller. For example:
ⓘ
fn load_file_content_as_string() -> Result<String> {
let file_stream = load_file().err_to_test_failure()?;
Ok(file_stream.to_string())
}
The Err
variant contains a [TestAssertionFailure
] which carries the data
of the (fatal) assertion failure which generated this result. Non-fatal
assertion failures, which log the failure and report the test as having
failed but allow it to continue running, are not encoded in this type.
Aliased Type§
enum Result<T> {
Ok(T),
Err(TestAssertionFailure),
}