The Negative Side of Mocking Tools
In this article, Brett Schuchert discusses how modern mocking tools affects positively our ability to work with legacy code and the possible negative implications of using mocking tools. These tools allow us to perform unit testing without actually changing the underlying code. He starts with a discussion about the challenges of unit testing and how mocking tools help to solve them; at least on the surface.
He argues however that performing some refactoring on some code structures could make them more testable using more traditional unit testing tools. The fact is that using powerful mocking tools like JMockIt could cover sometimes questionable design in code. His conclusion is not that you shouldn’t use mocking tools, but rather than using them sparingly during new development could lead to writing new code with more discipline. This article provides thinking content with many code examples and it should be considered by all developers using mocking tools, especially in a Java context.