user721588
user721588

Reputation:

Run maven test not in default src/test/java folder

I have a project containing pom.xml and some JUnit tests. Both pom.xml and unit tests are corrects. But problem is that tests are not in src/test/java folder (I cannot use this folder). Is it possible to tell maven to execute tests from another source folder (which is also in this project)?

Upvotes: 5

Views: 3699

Answers (1)

maba
maba

Reputation: 48045

It is enough to add this part to your pom:

<project>
    ...
    <build>
        <testSourceDirectory>src/int-test/java</testSourceDirectory>
    </build>
    ...
</project>

The test sources will be compiled during the test-compile phase and the maven-surefire-plugin will find the test classes too.

Upvotes: 8

Related Questions