When deciding if, when, what, and how to test, we should always be guided by this mindset.
<aside> 🛡️ We write tests to increase confidence in our code and its behavior.
</aside>
The only two users of a piece of code that we care about are:
When testing a piece of code, if we are testing implementation details, we are no longer testing behavior of either of our two users. Instead, we are testing for a third user: the test user. Therefore, we are not gaining any true confidence from the tests.
Rather than thinking about and looking at the code we're striving to test, we think about the use cases. When we do this, we keep the focus on the end behavior we're looking to get confidence in, rather than arbitrarily "covering" lines of code.
If a test does not give us any meaningful confidence that our code works to our two users as expected, it is not a valuable test.
We do not write or keep these tests in our codebase.