The purpose of unit tests is not really to check correctness at t=0, which is low-value and can be done via other means. It is to avoid future breakages and to be able to make changes with confidence. Write your tests with this in mind.
-
-
The return-on-investment of a unit test only goes up as a function of time elapsed and number of changes made. For a long-running project, it's the most valuable code you will ever write.
Show this threadThanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
In a world without deadlines, this would be true. In reality, we have to assess risk in various areas of our code and apply our limited testing resources accordingly. I've seen codebases with 100% coverage achieved mostly via unit testing which fail to test crucial scenarios.
-
I've also seen teams waste huge amounts of time unit testing trivial pieces of code at the expense of more significant tests. And then unit testing implementation details, which creates a lot of friction when it's time to refactor. Testing is not as simple as "test everything".
End of conversation
New conversation -
-
-
You can spend so much time obsessively writing tests that forward progress on product code slows to a crawl. Balance in everything...
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
You are basically protecting some function with your tests. That can also be a cost. In a fresh project I mostly avoid testing internals separately, as I don’t trust them to be the perfect abstractions.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
Disagree. You should test the underlying functionality that matters. This mitigates tech debt over time, and, more importantly, keeps testing in high regard; a repo of 500 respected tests is taken care of, whereas a repo of 5000 aimless tests invites disregard and carelessness.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.