Sunday, August 7, 2016

Why not to use PowerMock

In my opionion [sic], creating a new collaborating service is not bad primarily because it's untestable, but because it introduces coupling and undermines polymorphism, and similarly for the static invocations of the Database class. 
 http://blog.xebia.com/mocking-the-unmockable-too-much-of-a-good-thing/

So "testability" has always been more than just whether a class is literally testable in terms of lack of technical limitations. Author seems to suggest "testability" has really been a proxy argument for good OOP design.

Having realized this, I now understand what Misko Hevery meant when he said the following (unfortunately without elaborating):
 Yes I am aware of them, and I think it is a bad idea. You are trying to compensate bad design with Monkey Patching.
http://misko.hevery.com/2008/12/15/static-methods-are-death-to-testability/

No comments:

Post a Comment