3 ms·
I work to "assert one thing", and the assertions are added to help with debugging. I sometimes even assert starting conditions if they can at all change. Witho
by jpollock 4y ago
I work to "assert one thing", and the assertions are added to help with debugging. I sometimes even assert starting conditions if they can at all change.
Without a "assert one thing", what tends to happen is there will be cut-and-paste between tests, and the tests overlap in what they assert. This means that completely unrelated tests will have an assertion failure when the code goes wrong.
When you do a refactor, or change some behavior, you have to change _all_ of the tests. Not just the one or two that have the thing you're changing as their focus.
Think of tests that over-assert like screenshot or other diff-based tests, they are brittle.