[英]Maven not recognizing integration tests in multi-module project
I'm trying to set up integration testing for my multi-module Maven project using the failsafe plugin. 我正在尝试使用故障安全插件为我的多模块Maven项目设置集成测试。 In a smaller dummy project, I had the following structure: 在一个较小的虚拟项目中,我具有以下结构:
pom.xml
src
-main
--java
---com
----App.java
-test
--java
---com
----AppIT.java
Here was the relevant addition to the pom.xml: 这是pom.xml的相关附加内容:
<profiles>
<profile>
<id>failsafe</id>
<build>
<plugins>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.0</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
Everything worked fine and the test was detected when I ran mvn verify -Pfailsafe
. 一切正常,当我运行mvn verify -Pfailsafe
时检测到测试。
For the new project, I have the following structure: 对于新项目,我具有以下结构:
pom.xml
module-1
module-2
module-testing
-src
--test
---java
----com
-----Test1.java
-----Test2.java
-----...
-----RestIT.java
All of Test1.java through TestN.java are unit tests. 从Test1.java到TestN.java都是单元测试。 RestIT.java is the name of an empty integration test which I just want to be detected by the verify command in the same way that AppIT.java was detected in the old dummy project. RestIT.java是一个空的集成测试的名称,我只想由verify命令检测到它,就像在旧的虚拟项目中检测到AppIT.java一样。
Here is what I added to the pom.xml for the entire project (identical to what was in the pom.xml for the dummy Maven project): 这是我添加到整个项目的pom.xml中的内容(与虚拟Maven项目的pom.xml中的内容相同):
<profiles>
<profile>
<id>failsafe</id>
<build>
<plugins>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.0</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
The existing unit tests are detected in the output of mvn verify -Pfailsafe
, but the RestIT.java test is not. 在mvn verify -Pfailsafe
的输出中检测到现有的单元测试,但未检测到RestIT.java测试。 I've also previously seen the error for "the profile of failsafe not found" before and it's not present when I run that command with the above snippet added to the parent pom.xml. 我以前也曾见过“找不到故障安全的配置文件”的错误,当我在上面的代码片段添加到父pom.xml的情况下运行该命令时,该错误不存在。
If you're interested in seeing the entire maven command output or the whole pom.xml let me know and I'll add Dropbox links. 如果您有兴趣查看整个maven命令输出或整个pom.xml,请告诉我,我将添加Dropbox链接。
Try adding this to the module(s) with integration tests: 尝试通过集成测试将其添加到模块中:
<profiles>
<profile>
<id>failsafe</id>
</profile>
</profiles>
Note, the ID is the same. 注意,ID是相同的。 I suspect this will allow the module to pick up the profile contents. 我怀疑这将允许模块提取配置文件内容。 Profiles are not inherited by default. 默认情况下,不会继承配置文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.