Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

8
  • 5
    "[in Big Ball Of Mud kind code] ...unit tests, these do things opposite to how I use them in good code, like breaking at reasonable changes and failing to catch the real mistakes I make. Which is painful but not surprising - what else would one expect from testing units which have bad design to start with? Instead of helping you improve the design, unit tests often work to preserve bad code..." - I wrote about that in another answer Commented May 3, 2012 at 11:39
  • 6
    @gnat That depends on the direction the testing comes from. Unit tests are especially brittle when they delve into minutiae and when written after implementation, so unit testing becomes a fruitless catch-up exercise and therefore become very expensive to maintain. Targeted testing of legacy code with judicious refactoring can help, but only to a certain degree. OTOH, a green field behavior-driven project tends to result in tests that preserve the requirements instead of the tests, because changed requirements necessitate the removal of older unsuitable tests that no longer match requirements. Commented May 3, 2012 at 12:06
  • @S.Robins sounds like you favor unit tests in green field behavior-driven project. If so then I am 200% with you here; in cases like this unit tests are as close to silver bullet as it gets. And, yeah it feels fun to adopt tests to changing requirements - when things are understood, white box testing is cool Commented May 3, 2012 at 12:11
  • 3
    This question asked something similar, and the conclusion was that it was not worth doing it for them, as they would get payed to fix bugs later: programmers.stackexchange.com/q/64592/1249 Commented May 3, 2012 at 12:11
  • Oh the joys of answers starting with "You should"... Commented May 3, 2012 at 12:22