我有一些单元测试(src/test 文件夹中的 *Test.java 类,由 Surefire 插件执行)和其他一些集成测试(src/it 文件夹中的 *IT.java 类,由 Failsafe 插件执行):.xml 和 .txt当我运行 mvn install
时,报告会在文件夹 target/surfire-reports 和 target/failsafe-reports 中正确生成.
此外,我想要 html 报告:我认为最好的解决方案应该是使用 mvn site
, 以便也有 CSS 文件。
然而,现在只执行单元测试,所以只生成目标/surfire-reports,显然生成的唯一 html 文档是关于单元测试的。
下面的 POM 片段:
<build>
...
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
...
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
...
<goal>integration-test</goal>
<goal>verify</goal>
...
</plugin>
<plugin>
// definition of build helper maven plugin for the registration
// of the src/it folder
</plugin>
...
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.maven.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.19.1</version>
</plugin>
</plugins>
</reporting>
显然,mvn site
不执行集成测试目标,但我该如何解决?PS:一个愚蠢的解决方案是在 mvn install 之后运行 mvn site(没有清理),但我想要更聪明的东西。
最佳答案
There are three built-in build lifecycles: default, clean and site. The default lifecycle handles your project deployment, the clean lifecycle handles project cleaning, while the site lifecycle handles the creation of your project's site documentation.
所以命令应该是:
mvn clean verify site
(除非有特殊要求,否则请始终清洁您的工作空间)Maven Build Lifecycle Basics
关于maven - 如何使用 mvn site 命令生成集成测试报告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43050754/