gpt4 book ai didi

java - Maven-Surefire-Report 插件未生成报告

转载 作者:塔克拉玛干 更新时间:2023-11-03 04:33:42 67 4
gpt4 key购买 nike

如标题所示,我正在尝试在我的 maven 项目执行时生成 JUnit 结果的 HTML 报告。另一个人告诉我检查 maven-surefire-report 插件,看起来它有我想要的东西,但我似乎无法生成 HTML 文件。我希望只生成一个 HTML 文件,然后我可以将其放入我的老板的电子邮件中。我真的不想走将结果发布到网站的道路(至少目前不想)。

这是我的 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.jackson.core/jackson-databind -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-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>

据我所知,根据指南和我没有看过的内容,这就是我所需要的。只有 pom 依赖项和报告插件部分,但我仍然没有看到生成的 HTML 文件。

我感觉我缺少的部分会非常少,但我似乎找不到它。

最佳答案

默认报告应该位于 ${basedir}/target/site/surefire-report.html

我相信您可能需要在插件/依赖项中分别包含 maven-surefire-plugin 和 junit。

surefire 报告插件将自动解析 ${basedir}/target/surefire-reports 中匹配 TEST-.xml 的文件,但我相信您需要 maven-surefire-plugin 才能生成 TEST-.xml 文件

这是插件的文档。一种方法可能是运行构建并查看是否正在生成 TEST-*.xml 文件。

http://maven.apache.org/surefire/maven-surefire-plugin/index.html

关于java - Maven-Surefire-Report 插件未生成报告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39730203/

67 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com