4 ms·
If you wrote the test after you coded your unit,you would not know why it passed. It could be a false positive. When you move on to the next part of the requir
by PretzelFisch 9y ago
If you wrote the test after you coded your unit,you would not know why it passed. It could be a false positive.
When you move on to the next part of the requirement, you can ensure all your tests still pass.
Sometimes the tests give you the starting point of the problem, "what is the simplest way to get result x" with a way to rapidly get feed back that all the requirements are ment as the structure takes form and you refactor all the code.
- bluGill 9y agoI sometimes write tests that I know will pass. A common example is when the previous version of an algorithm had a bug in some special case. My new algorithm written from scratch doesn't have that special case at all so there is no test for it. However because the last version had that bug there is a lot of fear so I will write a test that it works even though it is inherent in my new algorithm that it works and at no point in the TDD cycle is that test the correct one to write.