Why not rely on existing conventions?
mvn clean test
will run unit tests via surefire.
mvn clean verify
will run integration tests via failsafe
You can use naming conventions or annotations to enforce selection.
thisIsAUnitTest.java will be executed by surefire (mvn test)
thisClassIsAnIT.java will be executed by failsafe (mvn verify)
HOW ?!
SureFire for Unit Tests
By default, the Surefire Plugin will automatically include all test classes with the following wildcard patterns:
"**/Test*.java" - includes all of its subdirectories and all java filenames that start with "Test".
"**/*Test.java" - includes all of its subdirectories and all java filenames that end with "Test".
"**/*TestCase.java" - includes all of its subdirectories and all java filenames that end with "TestCase".
Failsafe for integratino tests
By default, the Failsafe Plugin will automatically include all test classes with the following wildcard patterns:
"**/IT*.java" - includes all of its subdirectories and all java filenames that start with "IT".
"**/*IT.java" - includes all of its subdirectories and all java filenames that end with "IT".
"**/*ITCase.java" - includes all of its subdirectories and all java filenames that end with "ITCase".