The Cost of Maintaining Unit Tests
The change to the interface to Profile broke a number of tests in ProfileTest. We need to invest some effort to fix the tests, which points out one of the costs of having unit tests in the first place.
Refactoring is supposed to be an activity where we change the implementation of the code without changing its behavior. The tests are supposed to be a reflection of the behavior. But the reality is that we are changing the behavior of our classes, at least in terms of how we expose that behavior through the classes’ interfaces.
We accept the cost of fixing broken tests because their return on value can be far greater. We’ve mentioned elsewhere the benefits of having code with few defects, the benefit of being ...
Get Pragmatic Unit Testing in Java 8 with JUnit now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.