Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Run an already compiled unit test with Maven

I would like to know if it is possible to run a previously compiled test (using mvn test-compile) without having to recompile a project and its tests. I’m aware of the mvn -Dtest=TestClass#testMethod test command, but it does not fit my need.

More generally I’m trying to find a way to run unit tests is a specific order using a list of test names. Any idea would be appreciated.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading