0 votes
1 view
in Java by (10.2k points)

I have a maven2 multi-module project and in each of my child modules I have JUnit tests that are named Test.java and Integration.java for unit tests and integration tests respectively. When I execute:

mvn test

all of the JUnit tests *Test.java within the child modules are executed. When I execute

mvn test -Dtest=**/*Integration

none of the Integration.java tests get execute within the child modules.

These seem like the exact same command to me but the one with the -Dtest=/*Integration** does not work it displays 0 tests being run at the parent level, which there are not any tests

1 Answer

0 votes
by (46.1k points)

You can set up Maven's Surefire to run unit tests and integration tests separately. In the standard unit test phase you run everything that does not pattern match an integration test. You then create a second test phase that runs just the integration tests.

Here is an example:



























Welcome to Intellipaat Community. Get your technical queries answered by top developers !