3 ms·
• Keep regression tests around for up to a year — but most of those will be system-level tests rather than unit tests. • Keep unit tests that test key algorith
by sehugg 13y ago
• Keep regression tests around for up to a year — but most of those will be system-level tests rather than unit tests.
• Keep unit tests that test key algorithms for which there is a broad, formal, independent oracle of correctness, and for which there is ascribable business value.
• Except for the preceding case, if X has business value and you can text X with either a system test or a unit test, use a system test — context is everything.
• Design a test with more care than you design the code.
• Turn most unit tests into assertions.
• Throw away tests that haven’t failed in a year.
• Testing can’t replace good development: a high test failure rate suggests you should shorten development intervals, perhaps radically, and make sure your architecture and design regimens have teeth
• If you find that individual functions being tested are trivial, double-check the way you incentivize developers’ performance. Rewarding coverage or other meaningless metrics can lead to rapid architecture decay.
• Be humble about what tests can achieve. Tests don’t improve quality: developers do
- jmnicolas 13y agoThanks.
- Wohui 13y agoBeautiful.
- TwoBit 13y ago>> Throw away tests that haven’t failed in a year. That's absolutely f*ing crazy. Throwing those tests away makes it impossible for me to know that any changes I make to the implementation are OK.
- mempko 13y agoWhy? Don't you use assertions?
- smtddr 13y agoNo amount of assertions in production code can replace assertions of unit-tests; assuming the unittests are designed to try all known common & edge cases.
- TwoBit 13y agoAlso, assertions only flag code that gets executed when you test it. Unless you can be sure that you have tested every possible execution possibility before shipping, you cannot know if after shipping your code will execute something that you missed during testing. This happens a lot. Additionally, the unit tests allow me to safely maintain the code from the comfort of my own desk. If I relied only on assertions then I would literally have to send changes to all possible users and ask each of them to please test and tell me if they got any assertions. And do this for me three times a week for the next two years.
- mempko 13y agoWho said only?