News for hackers. Stuff that matters.
Re:UX clichés by usea on Sunday May 05, 2019 @10:05AM (#19832856)
- 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?

Re:UX clichés by Waterluvian on Sunday May 05, 2019 @10:13AM (#19832895)
This 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.
Re:UX clichés by mikeash on Sunday May 05, 2019 @07:42PM (#19835788)
You 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.
Re:UX clichés by AlexTWithBeard on Sunday May 05, 2019 @10:43AM (#19833033)
Well, 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.

Re:UX clichés by swiftcoder on Sunday May 05, 2019 @01:25PM (#19833830)
One finds a truly surprising number of bugs in tests and test frameworks. So yes, your tests need tests.
Re:UX clichés by gmueckl on Sunday May 05, 2019 @06:00PM (#19835358)
A 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.
Re:UX clichés by megaremote on Sunday May 05, 2019 @08:20PM (#19835934)
> 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.

Re:UX clichés by mLuby on Sunday May 05, 2019 @12:09PM (#19833466)
My tests run during tests, so they automatically have 100% test coverage. :D
Re:UX clichés by plorkyeran on Sunday May 05, 2019 @01:46PM (#19833953)
It'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.
Re:UX clichés by DonHopkins on Sunday May 05, 2019 @06:21PM (#19835444)
Always write recursive code. It tests itself!