테스트 악취
Here are some attributes of tests that suggest a design in trouble.
- Long setup code: If you have to spend a hundred lines creating the objects for one simple assertion, then something is wrong. Your objects are too big and need to be split.
- Setup duplication: If you can’t easily find a common place for common setup code, then there are too many objects too tightly intertwined.
- Long running tests: TDD tests that run a long time won’t be run often, and often haven’t been run for a while, and probably don’t work. Worse than this, they suggest that testing the bits and pieces of the application is hard. Difficulty testing bits and pieces is a design problem, and needs to be addressed with design. (The equivalent of is the ten-minute test suite. Suites that take longer than ten minutes inevitably get trimmed, or the application tuned up, so the suite takes ten minutes again.)
- Fragile tests: Tests that break unexpectedly suggest that one part of the application is surprisingly affecting another part. You need to design until the effect at a distance is eliminated, either by breaking the connection or by bringing the two parts together.
—Chapter 32, Test-driven development: by example
See also
- Test-implementation coupling
- Mock object smell