【问题标题】:Allure report is NaN% via allure-maven plugin通过 allure-maven 插件,Allure 报告为 NaN%
【发布时间】:2022-01-23 23:35:40
【问题描述】:

我尝试查看由 maven-plugin 和 JUnit 5 生成的 Allure 报告,但 html 页面为空

我通过mvn clean test 构建我的报告,然后我使用mvn allure:serve 并且它构建没有错误。但打开的诱惑站点是空的或包含 NaN 值。

使用allure serve target/surefire-reports 启动诱惑网站会生成正确的网页

构建日志不包含任何错误,并表示一切正常,生成后我在/allure-results 上发现了许多带有报告的 json 文件,其中包含项目测试和容器的信息:

[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< org.example:TestProject >-----------------------
[INFO] Building TestProject 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- allure-maven:2.10.0:serve (default-cli) @ TestProject ---
[WARNING] The artifact xml-apis:xml-apis:jar:2.0.2 has been relocated to xml-apis:xml-apis:jar:1.0.b2
[INFO] Allure installation directory C:\Users\Я\IdeaProjects\TestProject/.allure
[INFO] Try to finding out allure 2.8.1
[INFO] Generate Allure report (serve) with version 2.8.1
[INFO] Generate Allure report to C:\Users\Я\IdeaProjects\TestProject\target\site/allure-maven-plugin
[INFO] Found results directory C:\Users\Я\IdeaProjects\TestProject\allure-results
[INFO] Can't find information about categories.
[INFO] Generate report to C:\Users\Я\IdeaProjects\TestProject\target\site\allure-maven-plugin
Generating report to temp directory...
Report successfully generated to C:\Users\4483~1\AppData\Local\Temp\8774552783003673881\allure-report
Starting web server...
2021-12-22 22:16:25.525:INFO::main: Logging initialized @1032ms to org.eclipse.jetty.util.log.StdErrLog
Server started at <http://192.168.56.1:64312/>. Press <Ctrl+C> to exit

我的 pom.xml:

<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>org.example</groupId>
  <artifactId>TestProject</artifactId>
  <version>1.0-SNAPSHOT</version>

  <name>TestProject</name>
  <!-- FIXME change it to the project's website -->
  <url>http://www.example.com</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <aspectj.version>1.8.10</aspectj.version>
  </properties>

  <dependencies>
    <dependency>
      <groupId>io.qameta.allure</groupId>
      <artifactId>allure-junit5</artifactId>
      <version>2.17.2</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-engine</artifactId>
      <version>5.8.2</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.seleniumhq.selenium</groupId>
      <artifactId>selenium-java</artifactId>
      <version>4.1.0</version>
    </dependency>

    <dependency>
      <groupId>io.github.bonigarcia</groupId>
      <artifactId>webdrivermanager</artifactId>
      <version>5.0.3</version>
      <scope>test</scope>
    </dependency>

  </dependencies>

  <build>
    <plugins>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.21.0</version>
        <configuration>
          <testFailureIgnore>false</testFailureIgnore>
          <argLine>
            -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
          </argLine>
          <systemProperties>
            <property>
              <name>junit.jupiter.extensions.autodetection.enabled</name>
              <value>true</value>
            </property>
          </systemProperties>
        </configuration>
        <dependencies>
          <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-surefire-provider</artifactId>
            <version>1.2.0</version>
          </dependency>
          <dependency>
          <groupId>org.aspectj</groupId>
          <artifactId>aspectjweaver</artifactId>
          <version>${aspectj.version}</version>
          </dependency>
        </dependencies>
      </plugin>
      <plugin>
        <groupId>io.qameta.allure</groupId>
        <artifactId>allure-maven</artifactId>
        <version>2.10.0</version>
        <configuration>
<!--          <reportVersion>2.4.1</reportVersion>-->
          <buildDirectory>${project.basedir}</buildDirectory>
        </configuration>
      </plugin>
    </plugins>
  </build>

screenshot of site

【问题讨论】:

    标签: java maven junit allure


    【解决方案1】:

    我也遇到了同样的情况。请尝试将allure-junit5.version 更改为2.16.1,在我的情况下,这是最后一个正常工作的。 它上面的每一个在报告中的行为与 NaN% 相似


    更新:您可以使用2.16.1 以上的版本,但使用reportVersion 标签配置allure-maven 插件,例如对于版本2.17.2

    <plugin>
       <groupId>io.qameta.allure</groupId>
       <artifactId>allure-maven</artifactId>
       <version>2.11.2</version>
       <configuration>
           <reportVersion>2.17.2</reportVersion>
           <resultsDirectory>${project.build.directory}/allure-results</resultsDirectory>
           <reportDirectory>${project.build.directory}/allure-report</reportDirectory>
       </configuration>
    </plugin>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-02
      • 2016-05-17
      • 1970-01-01
      • 2023-03-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多