Java Testing with Maven

 Maven can be used to test Java application and libraries.  The following command can be used to execute the tests in a Maven managed project:

mvn test

Running a Single JUnit Testing with Maven

 A single JUnit test can be run by specifying the class name(s):

mvn -Dtest=LazyObjectRetrieverTest,Functional*Tests test

Running a Single JUnit Testing with Maven

 A single JUnit test can be run by specifying the class name(s):

mvn -Dtest=LazyObjectRetrieverTest,Functional*Tests test

Run Integration Tests with Maven

 Run integration tests with this Maven command, using the UAT and CHROME profiles:

$mvn integration-test -P UAT,CHROME

To execute only one test within a JUnit test class use # to separate the class and test method name.

$ mvn -P QA,CHROME -Dit.test=AcmeTestsIT#retreiveLatestNewUserLink integration-test^C

For more information on running integration tests with Maven see the Maven Failsafe Plugin documentation

See this guide for more information on Maven Failsafe Plugin integration test naming conventions:

http://maven.apache.org/surefire/maven-failsafe-plugin/examples/inclusion-exclusion.html


Separate Unit and Integration Test Name Configuration

See this Maven POM for an example of using custom names for Unit and Integration test classes .

Last Updated: 2020-09-21 12:55:53 -0600 (Mon, 21 Sep 2020) Date Created: 2012-02-18 17:13:53 -0600 (Sat, 18 Feb 2012)




back    |    top