How can I atomically run mvn tests (without rebuilding source code)?

南楼画角 提交于 2019-11-30 12:58:50

问题


I want to run a maven project lifecycle starting, and ending, with the unit tests.

How can I skip recompilation and re-resolution of dependencies and only run the test phase?


回答1:


If you start maven by calling a phase it will execute all lifecycle phases up to the one you are calling. For example, when calling

mvn test

all the phases before the test lifecycle phase will be execute too: the project will be validated, sources and resources will be generated and processed, sources will be compiled, the same will happen to test sources and resources and finally unit tests will be run.

But you can also call the plugin goal that is bound to a lifecycle phase. In the case of the test phase the bound goal is surefire's test mojo. So you could call

mvn surefire:test

and no other lifecycle phase will be executed. You can find the goals bound to each phase depending on the package type here.




回答2:


You can run :

mvn surefire:test



回答3:


Build your own lifecycle, or run the tests with something besides Maven (Ant, Gradle, your IDE, command-line JUnit runner, ...). That's the kind of restriction you live with when you're using Maven.



来源:https://stackoverflow.com/questions/14867073/how-can-i-atomically-run-mvn-tests-without-rebuilding-source-code

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