java 报告未使用 Maven-Surefire-Report 插件生成
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39730203/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Report not being generated with Maven-Surefire-Report plugin
提问by user1818298
As the title suggests, I'm trying to generate an HTML report of the JUnit results when my maven project executes. I was told to check out maven-surefire-report plugin by another person and it looks like it has what I'm wanting but I just can't seem to get the HTML file to generate. I'm looking to ONLY generate an HTML file that I could then put into an email for my bosses. I'm not really wanting to go down the road of having the results post to a site (at least not at the moment).
正如标题所暗示的,当我的 Maven 项目执行时,我试图生成 JUnit 结果的 HTML 报告。我被告知要查看另一个人的 maven-surefire-report 插件,看起来它有我想要的东西,但我似乎无法生成 HTML 文件。我希望只生成一个 HTML 文件,然后我可以将其放入我的老板的电子邮件中。我真的不想走在将结果发布到网站的道路上(至少目前不是)。
Here is what my pom section looks like for surefire (don't worry about missing tags. I'm copying and pasting the relevant sections, and trying not to paste company info, but know I have the proper opening / closing tags):
这是我的 pom 部分的样子(不要担心缺少标签。我正在复制和粘贴相关部分,并尽量不粘贴公司信息,但知道我有正确的开始/结束标签):
EDIT: Added full pom.
编辑:添加了完整的 pom。
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>myGroup</groupId>
<artifactId>myArtifact</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>myName</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/net.sourceforge.jtds/jtds -->
<dependency>
<groupId>net.sourceforge.jtds</groupId>
<artifactId>jtds</artifactId>
<version>1.3.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-test -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>1.4.0.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.3.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.6.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-beans -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>4.3.2.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.6.2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.Hymanson.core/Hymanson-databind -->
<dependency>
<groupId>com.fasterxml.Hymanson.core</groupId>
<artifactId>Hymanson-databind</artifactId>
<version>2.0.2</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.19.1</version>
<type>maven-plugin</type>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<type>maven-plugin</type>
</dependency>
</dependencies>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.19.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<outputDirectory>${basedir}/target/site/surefire-report.html</outputDirectory>
</configuration>
<!--<configuration>-->
<!--<outputDirectory>C:\Users\ab66378\Desktop</outputDirectory>-->
<!--</configuration>-->
</plugin>
</plugins>
</reporting>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
As far as I know, and according to the guides and what not I've looked at, this is all I need. Just the pom dependency and the reporting plugin section but I'm still not seeing an HTML file generated.
据我所知,根据指南和我没有看过的内容,这就是我所需要的。只是 pom 依赖项和报告插件部分,但我仍然没有看到生成的 HTML 文件。
I have a feeling the part that I'm missing is going to be very minimal but I just can't seem to find it.
我有一种感觉,我缺少的部分将非常少,但我似乎无法找到它。
采纳答案by Dan King
The default report should be located in ${basedir}/target/site/surefire-report.html
默认报告应位于 ${basedir}/target/site/surefire-report.html
I believe you might need to include maven-surefire-plugin and junit in the plugins/dependencies respectively.
我相信您可能需要分别在插件/依赖项中包含 maven-surefire-plugin 和 junit。
The surefire report plugin will automatically parse the files matching TEST-.xml in ${basedir}/target/surefire-reports but I believe you need the maven-surefire-plugin in order to generate the TEST-.xml files
surefire 报告插件将自动解析${basedir}/target/surefire-reports 中与 TEST- .xml匹配的文件,但我相信您需要 maven-surefire-plugin 才能生成 TEST-.xml 文件
Here is the documentation to the plugin. One way might be to run the build and see if the TEST-*.xml files are being generated.
这是插件的文档。一种方法可能是运行构建并查看是否正在生成 TEST-*.xml 文件。
http://maven.apache.org/surefire/maven-surefire-plugin/index.html
http://maven.apache.org/surefire/maven-surefire-plugin/index.html
回答by Arunakiran Nulu
configure as below
配置如下
<configuration>
<outputDirectory>${basedir}/target/newsite</outputDirectory>
</configuration>
using stand alone tool you can change the path like below
使用独立工具,您可以更改如下路径
mvn surefire-report:report -DoutputDirectory=newpath