不在默认的src/test/java文件夹中运行Maven测试 [英] Run maven test not in default src/test/java folder
本文介绍了不在默认的src/test/java文件夹中运行Maven测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含pom.xml
和一些JUnit
测试的项目. pom.xml
和单元测试均正确.但是问题是测试不在src/test/java文件夹中(我不能使用此文件夹).是否可以告诉maven从另一个源文件夹(也在此项目中)执行测试?
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)?
推荐答案
将这部分添加到pom中就足够了:
It is enough to add this part to your pom:
<project>
...
<build>
<testSourceDirectory>src/int-test/java</testSourceDirectory>
</build>
...
</project>
测试源将在test-compile
阶段进行编译,而maven-surefire-plugin
也将找到测试类.
The test sources will be compiled during the test-compile
phase and the maven-surefire-plugin
will find the test classes too.
这篇关于不在默认的src/test/java文件夹中运行Maven测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文