3 ms·
It's entirely possible to write code that passes an as yet tested desired piece of functionality. If you want to make sure that piece of functionality doesn't g
by swish_bob 8y ago
It's entirely possible to write code that passes an as yet tested desired piece of functionality. If you want to make sure that piece of functionality doesn't get rewritten out later, you probably still ought to write a test. This test never fails though, unless you deliberately force it to.
You _could_ just assume your test is correctly written, but I personally prefer to be sure by seeing it red at least once.
- josteink 8y agoI think you misunderstand. I'm not arguing against red tests. I'm arguing for them. What I'm arguing against is 1. writing the finished code, 2. writing green tests to "prove" the code correct, 3. trying to sabotage the finished code to "prove" that the tests works by making them red. Sounds crazy? That was what OP said he was doing!
- swish_bob 8y agoIt's quite possible that he's testing after. It's implied, but it isn't necessarily the case. Anyway, we all agree testing is good. And that a test you've never seen fail is bad. Personally, I try to delete exploratory code and try to use tests to drive out the _real_ implementation, but I'm going to admit that at least sometimes I'll write code that's inherently "safe", and then add a test afterwards for garbage inputs, for example.
- ramblerman 8y agoI'm pretty sure everyone understood. There are many ways write code.