Tests let you know that you broke the expected behavior. If you break the behavior and the test suite is still green, something is wrong with your tests. That may happen because of weak assertions (which we have discussed) or because the method is covered but not tested (this happens, as discussed). Also recall that I mentioned the work of Vera-Pérez and colleagues (2019) and the existence of pseudo-tested methods.
Whenever you write a test, make sure it will break if the behavior changes. The TDD cycle allows developers to always see the test breaking. That happens because the behavior is not yet implemented, but I like the idea of “let’s see if the test breaks if the behavior does not exist or is incorrect.” I am not afraid of purposefully introducing a bug in the code, running the tests, and seeing them red (and then reverting the bug).
Leave a Reply