Вы можете указать maven включить / исключить тест с помощью аргументов:
# Exclude one test class, by using the explanation mark (!)
mvn clean install -Dtest=!LegacyTest
# Exclude one test method
mvn clean install -Dtest=!LegacyTest#testFoo
# Exclude two test methods
mvn clean install -Dtest=!LegacyTest#testFoo+testBar
# Exclude a package with a wildcard (*)
mvn clean install -Dtest=!com.mycompany.app.Legacy*
Чтобы указать maven включить конкретный тест:
# Include one file
mvn clean install -Dtest=AppTest
# Include one method
mvn clean install -Dtest=AppTest#testFoo
# Include two methods with the plus sign (+)
mvn clean install -Dtest=AppTest#testFoo+testBar
# Include multiple items comma separated and with a wildcard (*)
mvn clean install -Dtest=AppTest,Web*
# Include by Package with a wildcard (*)
mvn clean install -Dtest=com.mycompany.*.*Test
Примечание: нам может потребоваться выйти "! "при использовании bash.
mvn clean install -Dtest=\!LegacyTest
Для выхода нам придется использовать обратную косую черту (\)