Can't suppress DriverManager's static initializer block

谁说胖子不能爱 提交于 2019-12-06 07:23:57
Mark Rotteveel

I suspect (but I am not certain) that Powermock is unable to prevent the static initializer from running for classes that are loaded by the system or bootstrap classloader (like the jre classes including those of the package java.sql are).


After posting to the Powermock Google Group, I got this response:

You can mock, suppress methods, stub methods etc in these classes since powermock 1.2.5 but you cannot suppress static initializers.

Josh

See this page: Google Groups PowerMock Group

You need to add to the class: @PowerMockIgnore("javax.management.*")

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