Timeline for Is there any value in writing a unit test that is a subset of another test?
Current License: CC BY-SA 3.0
9 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jan 13, 2015 at 1:50 | comment | added | Chris Hayes | @DocBrown I never said you claimed that. Just trying to add to the conversation here. | |
| Jan 12, 2015 at 22:09 | comment | added | Doc Brown | @ChrisHayes: I wrote "there is no need", not "there is no value" in it. | |
| Jan 12, 2015 at 21:49 | comment | added | Chris Hayes | @DocBrown The other value in explicitly checking with an assert is that it becomes clear to anyone examining the test that this is a failure of the code under test, and not the test itself. When my tests encounter unexpected exceptions, I always have to spend some time figuring out which one is actually wrong. | |
| Jan 12, 2015 at 20:16 | vote | accept | Mihai | ||
| Jan 12, 2015 at 16:06 | comment | added | Doc Brown | I think in the current situation the error message would probably be informative enough. But in general, that might not be the case. That's why I agree to you that the general approach for a case like this should be to think of a "merge", using two asserts. If it turns out that the test can be further simplified by leaving out one of the assert, fine. | |
| Jan 12, 2015 at 16:00 | comment | added | Telastyn | @DocBrown - I assumed as much, but I'm not familiar with Python's error messages to know if there may be value in having an assert failure instead of random exception/error for informative reasons. | |
| Jan 12, 2015 at 15:58 | comment | added | Doc Brown | I upvoted your answer though it misses one minor point. In Python, the second test will also fail when my_function does not return exactly two values, without any assert - because the assignment will result in an exception. So there is actually no need to use multiple asserts and two checks to test the same thing. | |
| Jan 12, 2015 at 15:39 | history | edited | Telastyn | CC BY-SA 3.0 | deleted 1 character in body |
| Jan 12, 2015 at 15:34 | history | answered | Telastyn | CC BY-SA 3.0 |