File tree Expand file tree Collapse file tree 2 files changed +31
-4
lines changed
Expand file tree Collapse file tree 2 files changed +31
-4
lines changed Original file line number Diff line number Diff line change @@ -187,10 +187,23 @@ It must return [`Result<()>`].
187187use googletest :: prelude :: * ;
188188
189189#[googletest:: test]
190- fn more_than_one_failure () -> Result <()> {
190+ fn failing_non_fatal_assertion () -> Result <()> {
191191 let value = 2 ;
192192 expect_that! (value , eq (3 )); // Just marks the test as having failed.
193- verify_that! (value , eq (2 ))? ; // Passes, but the test already failed.
193+ verify_that! (value , eq (2 ))? ; // Passes, so does not abort the test.
194+ Ok (()) // Because of the failing expect_that! call above, the
195+ // test fails despite returning Ok(())
196+ }
197+ ```
198+
199+ ``` rust
200+ use googletest :: prelude :: * ;
201+
202+ #[googletest:: test]
203+ fn failing_fatal_assertion_after_non_fatal_assertion () -> Result <()> {
204+ let value = 2 ;
205+ verify_that! (value , eq (3 ))? ; // Fails and aborts the test.
206+ expect_that! (value , eq (3 )); // Never executes, since the test already aborted.
194207 Ok (())
195208}
196209```
Original file line number Diff line number Diff line change @@ -298,10 +298,24 @@ use googletest::prelude::*;
298298# /* Make sure this also compiles as a doctest.
299299#[googletest::test]
300300# */
301- fn more_than_one_failure () -> Result<()> {
301+ fn failing_non_fatal_assertion () -> Result<()> {
302302 let value = 2;
303303 expect_that!(value, eq(3)); // Just marks the test as having failed.
304- verify_that!(value, eq(2))?; // Passes, but the test already failed.
304+ verify_that!(value, eq(2))?; // Passes, so does not abort the test.
305+ Ok(()) // Because of the failing expect_that! call above, the
306+ // test fails despite returning Ok(())
307+ }
308+ ```
309+
310+ ``` no_run
311+ use googletest::prelude::*;
312+
313+ #[googletest::test]
314+ fn failing_fatal_assertion_after_non_fatal_assertion() -> Result<()> {
315+ let value = 2;
316+ expect_that!(value, eq(2)); // Passes; test still considered passing.
317+ verify_that!(value, eq(3))?; // Fails and aborts the test.
318+ expect_that!(value, eq(3)); // Never executes, since the test already aborted.
305319 Ok(())
306320}
307321```
You can’t perform that action at this time.
0 commit comments