Maven :: run only single test in multi-module project

continuous integrationmavenunit testing

Is there any way to provide some command-line argument in order to skip all tests but one on some module? So I will not need to change pom.xml every time I will need to run another test?

For example, I want to create build configuration on TeamCity, and provide command-line arguments to run only single test in some module. Next time I will need to change it and run another test, and so on.

Perhaps it is not how CI is intended to be used, but still.

Best Answer

I assume you've read the docs about running a single test under surefire? What they don't tell you is how to do that in a sub-module:

mvn test -Dtest=testname -pl subproject

Where subproject is the project containing that test. From the mvn man page:

-pl,--projects arg Comma-delimited list of specified reactor projects to build instead of all projects. A project can be specified by [groupId]:artifactId or by its relative path.