You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

QAF框架(TestNG)下Allure Report无法生成问题求助

解决QAF 4.0.0-RC1集成Allure Report无法生成的问题

1. 替换错误的依赖配置

你当前引入的allure-cucumber5-jvm是适配Cucumber框架的依赖,但你的项目是基于TestNG的QAF框架,必须替换为Allure TestNG的官方依赖:

<dependency>
    <groupId>io.qameta.allure</groupId>
    <artifactId>allure-testng</artifactId>
    <version>2.23.0</version>
    <scope>test</scope>
</dependency>

2. 配置Allure TestNG监听器

有两种方式添加监听器:

  • 方式一:在TestNG配置文件中添加
    在你的testng.xml(或QAF使用的TestNG配置文件)里加入Allure监听器:
    <listeners>
        <listener class-name="io.qameta.allure.testng.AllureTestNg"/>
    </listeners>
    
  • 方式二:在Maven Surefire插件中配置
    如果不想修改TestNG配置文件,可在maven-surefire-plugin的系统属性中指定监听器:
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>3.2.5</version> <!-- 使用适配你项目的版本 -->
        <configuration>
            <systemPropertyVariables>
                <allure.results.directory>${project.basedir}/allure-results</allure.results.directory>
                <testng.listeners>io.qameta.allure.testng.AllureTestNg</testng.listeners>
            </systemPropertyVariables>
        </configuration>
    </plugin>
    

3. 验证结果生成

执行mvn test命令运行测试后,检查${project.basedir}/allure-results目录,正常情况下会生成JSON格式的Allure结果文件。

额外优化(可选)

如果需要快速查看HTML格式的Allure报告,可添加Allure Maven插件:

<plugin>
    <groupId>io.qameta.allure</groupId>
    <artifactId>allure-maven</artifactId>
    <version>2.12.0</version> <!-- 适配你的Allure版本 -->
    <executions>
        <execution>
            <goals>
                <goal>report</goal>
            </goals>
            <phase>post-integration-test</phase>
        </execution>
    </executions>
</plugin>

添加后执行mvn allure:serve,即可启动本地服务查看HTML报告。

注意事项

  • QAF内置报告和Allure报告可共存,不会互相干扰
  • 确保使用的Allure版本(2.23.0)与QAF 4.0.0-RC1无兼容性冲突,当前版本组合无已知问题

内容的提问来源于stack exchange,提问作者Renish K.R

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.13 01:23:10