3 ms·
Tests before code makes sense when fixing bugs. Red-green specifically. 1: get bug 2: write tests that should work, but don’t because of bug 3: fix bug 4: c
by theshrike79 4mo ago
Tests before code makes sense when fixing bugs. Red-green specifically.
1: get bug
2: write tests that should work, but don’t because of bug
3: fix bug
4: confirm fix by running tests
Makes things a LOT easier for people checking the PR, they can just confirm the tests are correct pretty much.
As a bonus the same bug can’t surface again.
- bashtoni 4mo agoYep, I'm in full agreement. When extending functionality of some already existing code it also generally makes sense to write tests first. I think the value is much lower (maybe even negative) when you're still trying to work out what shape the code will take, in an initial implementation. Of course, as others have pointed out, nuanced opinion doesn't get clicks or YouTube views.
- ttoinou 4mo agoOh I do that naturally as my rational problem investigation. Sometimes you can’t write a test for that, you need to test it yourself