3 ms·
You can get value out of writing a test after the fact. But the value is higher for a test that you have written before the code because you have seen the test
by felixge 16y ago
You can get value out of writing a test after the fact. But the value is higher for a test that you have written before the code because you have seen the test go from failing to passing. This way you know it will also fail if you break the code in the future.
I also think writing the test before the feature will cause you to write better assert statements. If you write the test afterwards you'll tend to either assert everything (which leads to every test breaking on a small change), or to be horribly confused about what to assert and what not.