@PowerMockIgnore at project level

北城以北 提交于 2019-12-05 08:01:50

I don't think that this is possible.

Keep in mind, in the end, it is JUnit that is executing those testcases. One by one. And JUnit knows nothing about a maven "project" around.

JUnit only knows about the elements within the test class it is about to process.

Thus: those statements need to to go into all your testcases; ideally only in those that really require it.

Final word: please don't get me wrong, but in my opinion your real problem is that you seem to use PowerMock indiscriminately in your project. That could indicate many of your developers dont know how to write testable code ... and then they "fix" that by turning to PowerMock. There is a certain chance that you will regret that sooner or later.

Edit: for learning how to write testable code --- start here!

Since PowerMock 1.7.0 you can specify packages to ignore using the configuration file.

powermock.global-ignore="org.myproject.*"

Multiple packages/classes can be specified using comma:

powermock.global-ignore="org.myproject.*","org.3rdpatproject.SomeClass"

This configuration is applied to all test classes that in the classpath. You may enable the configuration by creating by adding this file to the classpath:

org/powermock/extensions/configuration.properties

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