Hacker News new | ask | show | jobs
by torginus 562 days ago
I disagree in my experience, poorly designed tests test implementation rather than behavior. To test behavior you must know what is actually supposed to happen when the user presses a button.

One of the issues with getting high coverage is that often tests need to be written for testing implementation, rather than desired outcomes.

Why is this an issue? As you mentioned, testing is useful for future proofing codebases and making sure changing the code doesn't break existing use cases.

When test look for desired behavior, this usually means that unless the spec changes, all tests should pass.

The problem is when you test implementation - suppose you do a refactoring, cleanup, or extend the code to support future use cases - the test start failing. Clearly something must be changed in the tests - but what? Which cases encode actual important rules about how the code should behave, and which ones were just tautologically testing that the code did what it did?

This introduces murkiness and diminishes the value of tests.