3 ms·
Principles I've found: * A test should accept any correct behaviour from the tested code. Anything which is not in the requirements, should not be enforced by
by dspeyer 13y ago
Principles I've found:
* A test should accept any correct behaviour from the tested code. Anything which is not in the requirements, should not be enforced by the test.
* A test should not use the same logic as the code to find the "right" answer.
* A function whose semantics are likely to be changed in the next refactor should not be invoked from a test.
* Whenever a test fails, make a note of whether you got it to pass by changing the test or by changing the code. If it's the test more than 2/3 of the time, it's a bad test.
* If you can't write a good test, don't write a test at all. See if you can write a good test for the code that calls this code instead.