4 ms·
Seems like a neat and very clever tool, but why would you use a test case as an example? Maintainability in unit tests is nowhere near as important as with actu
by Edd314159 14y ago
Seems like a neat and very clever tool, but why would you use a test case as an example? Maintainability in unit tests is nowhere near as important as with actual implementation code (refactoring eventually may even hinder the documentary aspect of test code).
- h2s 14y agoI respectfully disagree. If you don't treat test code with the same respect as production code, rot sets in. Rot in the test suite discourages programmers from trusting, augmenting and maintaining it, until it eventually stops being used altogether. The most common type of rot in test code is caused by lazily copy/pasting vast blocks of setup code. The reason this is bad is that when subtle architectural changes break that setup process, somebody has to waste hours fixing 50 tests. Refactoring such code into a setUp method is the usual way of avoiding this.
- beberlei 14y agoI disagree heavily. Refactoring tests is as important as refactoring "production" code. Following the four elements of simple design (http://www.jbrains.ca/permalink/the-four-elements-of-simple-design http://www.jbrains.ca/permalink/the-four-elements-of-simple-...) you can use test refactorings to find better names and detect need for abstractions. Tests with lots of duplication, for example in the test setup, get hard to maintain and developers tend to abandon them more easily (my own experience).
- wilmoore 14y agoUnfortunately, this is a very common mistake made by those that treat their tests a an after-thought. Tests should be cared for and maintained as much as (or perhaps even more than) the production code. If tests are difficult to read or reason about, it is much more likely that they will become stale, brittle, or worse, be ignored. If one does not plan to keep tests well-maintained, might as well never add them in the first place.