3 ms·
It's not about it being hard to tell which assertion failed. It's about being hard to tell what the cause of the failure was. When every test calls ->run_base_
by xhxivuvy 4y ago
It's not about it being hard to tell which assertion failed. It's about being hard to tell what the cause of the failure was.
When every test calls ->run_base_tests() before running it's own assertion sometimes things fail before you get to the root cause assertion.
The other problem of stacking assertions is that you'll see the first failure only. There may be more failures that give you a better picture of what's happening.
Having each assertion fail separately gives you a clearer picture of what's going wrong.
Fwiw, the book doesn't suggest what the reader is saying. It says what I've said above more or less.
You don't need to always stick to the rule but it generally does improve things to the point I now roll my eyes when I come across tests with stacked assertions and lots of test harness code that runs it's own assertions, I just know I'm in for a fun time.