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)?
-
in another source folder - src/int-test/javauser721588– user7215882012-11-06 19:56:50 +00:00Commented Nov 6, 2012 at 19:56
-
1I'm sure you have great reasons why you can't use src/test/java. So I'm only going to ask "why?" because nobody has answered your question so far. (Maybe the answer will provide more insight.) One of the first things I learned about Maven was that you really should adapt to its conventions because it's just painful if you don't. That's the whole idea of "configuration vs. convention."Marvo– Marvo2012-11-06 20:16:33 +00:00Commented Nov 6, 2012 at 20:16
-
Are these tests really unit tests? Based on the name of the folder i assume these tests are integration tests. If this is true you shouldn't use maven-surefire-plugin for such purposes. Better is to use maven-failsafe-plugin for such integration-tests.khmarbaise– khmarbaise2012-11-06 22:02:11 +00:00Commented Nov 6, 2012 at 22:02
Add a comment
|
1 Answer
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.
1 Comment
Nat Ritmeyer
Under maven 3.6.2 this results in the following error:
[ERROR] Some problems were encountered while processing the POMs: Malformed POM ....../pom.xml: Unrecognised tag: 'testSourceDirectory' (position: START_TAG seen ...<build><testSourceDirectory>.