News for hackers. Stuff that matters.
Re:I have complicated feelings about TDD by rcxdude on Thursday August 18, 2022 @11:55AM (#32511334)
One reason why TDD can be a good idea is the cycle involves actually testing the test cases: if you write the test, run it and see that it fails, then write the code, then run the test again and see that it succeeds, you can have some confidence the test is actually testing something (not necessarily the right thing, but at least something). Wheras if you're writing the test after writing the code and expect that it will succeed the first time you run it, it's quite possible to write a test which doesn't actually test anything and will always succeed. (There are other techniques like mutation testing which may get you a more robust indication that your tests actually depend on the state of your software, but I've rarely seem them used in practice).
Re:I have complicated feelings about TDD by dgunay on Thursday August 18, 2022 @05:05PM (#32514889)
Good point. Sometimes I cheat and implement before I test, but often when I do that I'll comment & uncomment the code that actually does the thing so I can see the tests go from red to green.

Have been meaning to try mutation testing as a way of sussing out tests that cover lines but don't actually test behavior.

Re:I have complicated feelings about TDD by majikandy on Friday August 19, 2022 @02:51AM (#32518157)
Snap, me too, amazing how many times it catches a simple mistake too like a < instead of > that you were certain you got the right way round as you wrote it.
Re:I have complicated feelings about TDD by pmarreck on Thursday August 18, 2022 @12:45PM (#32512000)
This is a great point. You're literally testing the test validity as you go.