Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
427 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...