93 ms·
- if your code isn't important enough to be tested, it's not important to be written Does this rule cover all code? Do your tests, which are code themselves, n
by usea 7y ago
- if your code isn't important enough to be tested, it's not important to be written
Does this rule cover all code? Do your tests, which are code themselves, not need their own tests? If not, what is special about a test that you know it's correct, when there is no faith in in non-test code?
Is it possible to write your program entirely out of the special "test" code, so that it's always correct and doesn't need to be tested?
- Waterluvian 7y agoThis is the danger of dumb rules like this. Nothing's universally true. Part of what an engineer is paid for is knowing what should be tested to what extent.
- AlexTWithBeard 7y agoWell, the cliche apparently tries to cover all the code, which, as you correctly said, is non-practical. The problem is that, like all other cliches, it sounds very convincing and it may take quite some time for the young inexperienced mind to rebuff it.
- mLuby 7y agoMy tests run during tests, so they automatically have 100% test coverage. :D
- plorkyeran 7y agoIt's not all that uncommon to have test code which is never actually run. Usually just because of disabled tests or leftover helper functions that are no longer used, but sometimes due to bugs in the tests themselves. Turning on code coverage tracking for the test code itself can sometimes reveal some interesting things.
- DonHopkins 7y agoAlways write recursive code. It tests itself!
- swiftcoder 7y agoOne finds a truly surprising number of bugs in tests and test frameworks. So yes, your tests need tests.
- gmueckl 7y agoA classic case of this bug is "I don't think this test case is doing what you think it is doing". I've produced my share of test cases that were elaborate duds.
- mikeash 7y agoYou don’t necessarily need automated tests, but you absolutely do need to test your tests. With any new test, I always verify that 1) it passes with the fix 2) it fails without the fix. Many programmers skip step 2 and it’s a good way to end up with tests that don’t test what you think they do.
- megaremote 7y ago> Do your tests, which are code themselves, not need their own tests? The tests of the tests is your original code. They are testing each other.