While ASSERT_* macros cause termination of test case, EXPECT_* macros continue its evaluation.
I would like to know which is the criteria to decide whether to use one or the other.
While ASSERT_* macros cause termination of test case, EXPECT_* macros continue its evaluation. I
Share
Use
ASSERTwhen the condition must hold – if it doesn’t the test stops right there. Use this when the remainder of the test doesn’t have semantic meaning without this condition holding.Use
EXPECTwhen the condition should hold, but in cases where it doesn’t we can still get value out of continuing the test. (The test will still ultimately fail at the end, though.)The rule of thumb is: use
EXPECTby default, unless you require something to hold for the remainder of the tests, in which case you should useASSERTfor that particular condition.This is echoed within the primer: