I would argue that there is no need for EXPECT (or at least, this is not a good demonstration of the need). If your method does not work for *any* test it should fail, and that defect should be fixed and tested before you fix another, otherwise you might be chasing your tail trying to figure out which change to the code might have introduced another defect. One fix at a time. It insures boolean accuracy when fixing defects, and supports agile development.
I agree, you should only *fix* one bug at a time. BUT Knowing which tests pass and which ones fail can give you a hint what the underlying bug is. It definitely helps to have more hints than fewer hints. It is best to use EXPECT over ASSERT if the tests are orthogonal, and use ASSERT over EXPECT if they are dependent.
I would argue that there is no need for EXPECT (or at least, this is not a good demonstration of the need). If your method does not work for *any* test it should fail, and that defect should be fixed and tested before you fix another, otherwise you might be chasing your tail trying to figure out which change to the code might have introduced another defect. One fix at a time. It insures boolean accuracy when fixing defects, and supports agile development.
ReplyDeleteI agree, you should only *fix* one bug at a time. BUT Knowing which tests pass and which ones fail can give you a hint what the underlying bug is. It definitely helps to have more hints than fewer hints. It is best to use EXPECT over ASSERT if the tests are orthogonal, and use ASSERT over EXPECT if they are dependent.
DeleteI have a fundamental, probably naive, question: in "ASSERT: Fails fast, aborting the current function", what exactly is "the current function"?
ReplyDeletePerhaps you could give an explicit example.
For instance in your ASSERT sample, what is the function aborted in the assert:
ASSERT_TRUE(fp = fopen(path, "r"))
<< "Failed to open " << path;
Is it really the Test "FileGeneratorTest" that is aborted and not some "function"?
Peter Schwenn
The current TEST(...) function.
Delete