News for hackers. Stuff that matters.
Re:Dependency injection is not a virtue by nfm on Sunday January 06, 2013 @03:42PM (#5017637)
That's not TDD. You define the expected behaviour first (which still can be wrong, now or in the future - they're based on your current assumptions/spec/other mutable thing), then ensure the code produces output that matches your expectations. Your output is now as correct as your understanding of the solution.
Re:Dependency injection is not a virtue by a_c_s on Sunday January 06, 2013 @04:05PM (#5017720)
Your output is still only as correct as your specification of your initial assumptions.

For example, lets say you make a mistake in your test so you are checking (result = expected_result), which is always true, instead of (result == expected_result). Now when you write your code, you run the test and it passes.

In this case your code may or may not be correct, and the test, which contains a bug, does not catch it. But the bug is not a fundamental misunderstanding of the problem, rather a simple mistake in writing the test. Following strict TDD doesn't prevent this.

Re:Dependency injection is not a virtue by swanson on Sunday January 06, 2013 @07:36PM (#5018510)
"Following strict TDD doesn't prevent this"

Actually, following strict TDD does prevent this.

You must see a test fail before you make it pass. It goes "Red -> Green -> Refactor" not just "Green -> Refactor". Even if a valid test case passes on the first time, one should modify the test (or the code) in a known way to cause an expected failure.

Your premise (tests are only as correct as the spec of initial assumptions) is correct, but your supporting example is not.