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)
Some TDD people selling “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 that result 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.”
Purpose of tests: ensure code works as expected, prevent regressions.
Purpose is defeated if you don’t know how expectations would be missed or what kind of regression could it prevent.
“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 validates
calls.
don’t write test that won’t fail.
Except for environment setup difficulties, complicated tests are a symptom of complicated code.
Object Orgy – an antipattern (negation 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 either 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?