TL; DR:使用maven,我想test
在测试实际运行之前在阶段开始时运行一个插件目标.什么是干净的方式呢?
我想在测试实际运行之前打印一条消息.因此,我想在测试阶段开始时使用echo插件的echo
目标(告诉用户如果每个测试都失败了,他最好看一下,因为他应该首先设置一个测试环境)README
尝试n°1
一个简单的办法可以是运行这个插件在前一阶段,process-test-classes
.
它有效,但将此任务绑定到此阶段似乎在语义上不正确...
尝试n°2
根据Maven文档,When multiple executions are given that match a particular phase, they are executed in the order specified in the POM, with inherited executions running first.
我试图明确设置surefire
插件:
...com.soebes.maven.plugins maven-echo-plugin 0.1 test echo *** If most tests fail, make sure you've installed the fake wiki. See README for more info *** ... org.apache.maven.plugins maven-surefire-plugin 2.16 test test
但测试在我的消息打印之前运行.
所以,简而言之:有没有办法达到我的目标,或者我应该坚持" process-test-classes
解决方案",即使它看起来有点"hacky"?
谢谢!