Why not PowerMock

KKO picture KKO · May 11, 2015 · Viewed 14.1k times · Source

I am working on a project where we are currently doing testing with JUnit and Mockito. Now I am trying to find out what would be the side effects of adding PowerMock to the mix.

What are its disadvantages, any dependencies I should know about, any stability issues?

I saw it supports Java 8. Are there any issues there? From what I've read, getting Java 7 support was quite a long road.

EDIT: I guess a questions that would sum it all would be:

What would be the reasons to not use PowerMock?

Answer

wsl picture wsl · May 11, 2015

Generally if you start new project and you (want to/ are forced) to use PowerMock because of the architecture of your code it means that this architecture is bad and needs improvement. Power Mock gives you access to mock static methods, constructors etc. and this means that your code is not following best programming principles.

Power Mock should be used in legacy applications where you cannot change the code which has been given to you. Often such code does not have unit/integration tests and even small change can result in bugs in application.