Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple test sets in Maven

I have written a REST server (in Java using RestEasy) with a unit test suite written in Scala. The test suite uses the mock server provided by RestEasy and runs with every Maven build.

I would like to create a second functional test suite that calls an actual tomcat server and exercises each REST service. I do not want this new suite to run with every build, but only on demand, perhaps controlled with a command line argument to Maven.

Is it possible to create multiple independent test suites in a Maven project and disable some from automatic running, or do I need to create a separate Maven project for this functional suite? How can I segregate the different functional suite code if these tests are in the same project with the unit tests (different directories)? How do I run a selected suite with command line arguments?

like image 647
Ralph Avatar asked May 12 '11 11:05

Ralph


1 Answers

I never used it myself but I am aware of maven integration tests run by the Maven Failsafe plugin.

As the surefire plugin by default includes the tests named **/Test*.java, **/*Test.java, **/*TestCase.java the failsafe plugin runs the **/IT*.java, **/*IT.java, **/*ITCase.java tests.

Both test approaches have different intentions which seems to match part of your needs. It might be worth to have a look.....


Another approach would be to use maven profiles and specifiy different surefire includes for each profile.

like image 114
FrVaBe Avatar answered Oct 14 '22 04:10

FrVaBe