Skip the test phase:
MVN package-dskiptests
Temporarily skip the compilation of the test code:
MVN package-dmaven.test.skip=true
Maven.test.skip also controls the behavior of the Maven-compiler-plugin and maven-surefire-plugin two plug-ins, skipping compilation and skipping tests.
Specifying Test classes
MVN test-dtest=randomgeneratortest
The test class that starts with random and ends with test
MVN test-dtest=random*test
Specify multiple test cases separated by commas
MVN test-dtest=atest,btest
Specifies that even without any test cases, do not error
The test parameter must match at least one Test class, or it will error and cause the build to fail. You can use the following configuration to specify that you do not make any error even if you do not have any test cases.
MVN test-dtest-dfailifnotests = False
Pom file configuration contains and excludes test cases
Use * */* Test.java to match all Java classes ending with tests. Two asterisk * * to match any path, an asterisk * is used to get 0 or more characters except the path style character. You can also use excludes to exclude some test classes.
<plugin>
<groupId>org.apahce.maven.plugins<groupId>
<artifactId> maven-surefire-plugin</artifactid>
<version>2.5</version>
<configuration>
<includes>
<include>**/*Tests.java</include>
</includes>
</ Configuration>
</plugin>