java Maven surefire-report未在存储库中生成报告

kulphzqa  于 2022-12-10  发布在  Java
关注(0)|答案(1)|浏览(218)

当我运行mvn surefire-report:report时,它应该会生成一个HTML文件repo/target/site/surefire-report.html,虽然它在本地测试时会这样做,但它不会将其添加到我们的GitHub仓库中。
下面是我们的pom.xml

<?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>com.com.csapat</groupId>
    <artifactId>Izsakazsivany</artifactId>
    <version>1.0-SNAPSHOT</version>
    <properties>
        <maven.compiler.source>15</maven.compiler.source>
        <maven.compiler.target>15</maven.compiler.target>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>5.7.0</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <reporting>
         <plugins>
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-surefire-report-plugin</artifactId>
                 <version>3.0.0-M5</version>
             </plugin>
         </plugins>
    </reporting>
    <build>
        <testSourceDirectory>src/main/test/java/com/csapat</testSourceDirectory>
        <finalName>izsakazsivany</finalName>
        <plugins>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.0</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

这是maven.yml

name: Java CI with Maven

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: Set up JDK 1.8
      uses: actions/setup-java@v1
      with:
        java-version: 1.8
    - name: Build with Maven
      run: mvn clean install
    - name: Test
      run: mvn test
    - name: Report
      run: mvn surefire-report:report

实现这一点还缺少什么?当在存储库中运行时,我需要指定在哪里生成它吗?如果需要,它应该在.xml或.yml中吗?如果答案是显而易见的,对不起,但我发现导航apache的文档站点相当困难。

kgsdhlau

kgsdhlau1#

要更改生成的输出报告沿着其他项目报告的位置,maven-site-plugin和maven-surefire-report-plugin的outputDirectory属性都应设置为所需的备用位置。

<project>
  [...]
  <reporting>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-report-plugin</artifactId>
        <version>3.0.0-M5</version>
        <configuration>
          <outputDirectory>${basedir}/target/newsite</outputDirectory>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-site-plugin</artifactId>
        <version>2.1</version>
        <configuration>
          <outputDirectory>${basedir}/target/newsite</outputDirectory>
        </configuration>
      </plugin>
    </plugins>
  </reporting>
  [...]
</project>

要使用独立目的更改生成得输出报告得位置,应将outputDirectory属性设置为新路径:

mvn surefire-report:report -DoutputDirectory=newpath

相关问题