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

Allure报告未显示io.qameta.allure.kotlin.Allure.step步骤问题

问题:Allure Kotlin 步骤未在报告中显示

在测试项目中使用io.qameta.allure.kotlin.Allure.step方法,期望步骤能在Allure报告中展示,但未能实现。

代码示例:

step("Create task") {
    client.createTask(task)
}

Allure相关插件与依赖配置:

plugins {
    kotlin("jvm") version "2.0.21"
    id("io.qameta.allure") version "2.12.0"
}

dependencies {
    // 其他非Allure依赖
    // ...
    // AspectJ Weaver
    runtimeOnly("org.aspectj:aspectjweaver:1.9.22.1")
    // JUnit
    testImplementation("org.junit.jupiter:junit-jupiter-api:5.11.3")
    testImplementation("org.junit.jupiter:junit-jupiter-engine:5.11.3")
    // Allure
    testImplementation("io.qameta.allure:allure-junit5:2.29.0")
    testImplementation("io.qameta.allure:allure-kotlin-commons:2.4.0")
}

执行测试并通过allureServe生成报告后,报告包含测试结果,但未显示步骤。


解决方法

  • 统一依赖版本:当前allure-junit5(2.29.0)与allure-kotlin-commons(2.4.0)版本差距过大,Allure Kotlin组件需与Allure Java核心版本兼容。建议将allure-kotlin-commons升级至与allure-junit5匹配的版本。

  • 补充Kotlin适配依赖:仅引入allure-kotlin-commons不足以支持JUnit5环境下的步骤追踪,需添加对应适配依赖:

    testImplementation("io.qameta.allure:allure-kotlin-junit5:2.29.0")
    
  • 配置AspectJ织入:Allure步骤追踪依赖AspectJ,需在测试任务中配置weaver参数:

    tasks.withType<Test> {
        useJUnitPlatform()
        jvmArgs("-javaagent:${classpath.find { it.name.contains("aspectjweaver") }?.absolutePath}")
    }
    
  • 确认方法导入:确保step方法是从io.qameta.allure.kotlin.Allure类导入,避免混淆其他类的同名方法。

内容的提问来源于stack exchange,提问作者somehow

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.16 02:13:16