PowerMock - Mocking static system class throws IllegalStateException

自作多情 提交于 2019-12-06 12:33:00

Try adding File.class to @PrepareForTest.

try the org.powermock.reflect.internal.WhiteboxImpl.newInstance() method to create the object of the class and then call method directly. 1) this will suppress the constructor of the class 2) if your class contains static block then use suppressStaticInitilaizationFor to suppress that.

regards Anil Sharma

Add File.class to @PrepareForTest and check the imports of replay and verify. They should be from PowerMock.

DhruvG

I think you need to suppress constructor

Check this http://code.google.com/p/powermock/wiki/SuppressUnwantedBehavior

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!