Maven (Surefire):从 src/test/java 复制测试资源 [英] Maven (Surefire): copy test resources from src/test/java

查看:30
本文介绍了Maven (Surefire):从 src/test/java 复制测试资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Maven 的 Surefire(测试)插件mvn test-compilesrc/test/resources 中的文件复制到 target/test-类.它编译src/test/java中的.java,并将编译好的.class文件复制到target/test-classes.

Maven's Surefire (testing) pluginmvn test-compile copies files in src/test/resources to target/test-classes. It compiles .java in src/test/java, and copies the compiled .class files to target/test-classes.

但是它不会从src/test/java中复制资源,可以把测试资源放在.java的同目录下比较方便它们是资源的类,而不是 src/test/resources 中的并行层次结构.

But it doesn't copy resources from src/test/java, and it's more convenient to be able to put test resources in the same directory as the .java classes they are resources for, than in a parallel hierarchy in src/test/resources.

是否可以让 Maven 从 src/test/java 复制资源?

Is it possible to get Maven to copy resources from src/test/java?

推荐答案

资源复制都是通过maven-resource-plugin完成的,如果你阅读了它的文档,你会看到如何添加从src/复制资源测试/java.

The resource copying is all done by the maven-resource-plugin, and if you read the doc thereof you will see how to add copying of resources from src/test/java.

参见 http://maven.apache.org/plugins/maven-resources-plugin/testResources-mojo.html 用于 test-resources 目标,它包含在默认生命周期中.

See http://maven.apache.org/plugins/maven-resources-plugin/testResources-mojo.html for the test-resources goal, which is included in the default lifecycle.

然后查看http://maven.apache.org/pom.html,然后寻找<testResources>.

这篇关于Maven (Surefire):从 src/test/java 复制测试资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆