These are Robert C. Martin's rules for TDD:
- You are not allowed to write any production code unless it is to make a failing unit test pass.
- You are not allowed to write any more of a unit test than is sufficient to fail; and compilation failures are failures.
- You are not allowed to write any more production code than is sufficient to pass the one failing unit test.
When I write a test that seems worthwhile but passes without changing production code:
- Does that mean I did something wrong?
- Should I avoid writing such tests in the future if it can be helped?
- Should I leave that test there or remove it?
Note: I was trying to ask this question here: http://programmers.stackexchange.com/questions/189858/can-i-start-with-a-passing-unit-testCan I start with a passing unit test? But I wasn't able to articulate the question well enough until now.