They give a false sense of security,
while lack of tests is a screaming call-to-action.
Instead of preventing regressions,
bad tests will make regressions creep up in qa/production
even more often than untested code.
(“We have tests for it so we don’t need to click.”)
(in order of importance)
Popular “if you don’t know how to implement it, write test cases for it” meme.
Result: ugly, bad-written code which needs refactoring before it was even created, with lots of tests for edge cases coming from bad, un-considered code in the first place.
If you don’t have an idea, think more: read, talk to people, go for a walk.
“First solve the problem, then write the code.”
Remember the purpose of tests?
Purpose is defeated if test won’t fail.
“Fails only if method is removed” is not a good reason to keep the test.
If a test can’t fail in reasonable scenarios, don’t write it.
Frequent offender: application tests for simple
don’t write test that won’t fail.
Except for environment setup difficulties, complicated tests are a symptom of complicated code.
See: Object Orgy – an antipattern (violation of Law of Demeter).
…covering this class from a high level and refactor the hell out of it.
Don’t. Just don’t.
Duplication indicates shitty, repeated code or shitty, repeated tests. Often both.
Tests are still code: they are a cost to develop and cost to maintain.
Make them worth the cost.
What are the bad reasons you know?