[英]Maven ear and failsafe
I am trying to move some integration tests into the project that assembles the final EAR.我正在尝试将一些集成测试移到组装最终 EAR 的项目中。 Test I want to run are in src/test/java/it.
我想运行的测试在 src/test/java/it 中。 There is nothing in src/main.
src/main 中没有任何内容。 However, when the build executes tests dont run and following message is displayed:
但是,当构建执行测试时不运行并显示以下消息:
[INFO] --- maven-failsafe-plugin:2.19.1:integration-test (integration-test) @ project ---
[INFO] No tests to run.
If I change the packaging tests execute with same exact failsafe configuration.如果我更改包装测试,则使用完全相同的故障安全配置执行。 Why and how is EAR plugin different?
EAR 插件为何以及如何不同? Is there a way to run tests after building an EAR?
有没有办法在构建 EAR 后运行测试?
First you should locate your tests into src/test/java
and simply naming accordingly the naming conventions of maven-failsafe-plugin which looks like this:首先,您应该将您的测试定位到
src/test/java
并相应地命名maven-failsafe-plugin的命名约定,如下所示:
<includes>
<include>**/IT*.java</include>
<include>**/*IT.java</include>
<include>**/*ITCase.java</include>
</includes>
Furthermore if you configured maven-failsafe-plugin accordingly to the documentation like this:此外,如果您根据如下文档配置了 maven-failsafe-plugin:
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.19.1</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
[...]
</project>
then maven-failsafe-plugin will be executed during the integration-test
phase which is after the package
phase (where the ear file will be packaed).然后 maven-failsafe-plugin 将在
package
阶段之后的integration-test
阶段执行(ear 文件将被打包)。 So you can simply run maven via:因此,您可以通过以下方式简单地运行 maven:
mvn clean verify
The different behaviour is caused by the ear
packaging.不同的行为是由
ear
包装引起的。
As documented here , this packaging only has lifecycle bindings for the phases generate-resources
, process-resources
, package
, install
and deploy
.如此处所述,此打包仅具有阶段
generate-resources
、 process-resources
、 package
、 install
和deploy
生命周期绑定。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.