【问题标题】:Allure report is empty when use Allure2+Junit5+Gradle+Selenide使用 Allure2+Junit5+Gradle+Selenide 时,Allure 报告为空
【发布时间】:2017-07-11 17:08:45
【问题描述】:

我的 build.gradle 是:

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'org.junit.platform.gradle.plugin'
apply plugin: 'io.qameta.allure'

defaultTasks 'clean', 'test'

ext.junitJupiterVersion = '5.0.0-M4'
ext.selenideVersion = '4.4.3'

compileTestJava {
    sourceCompatibility = 1.8
    targetCompatibility = 1.8
    options.encoding = 'UTF-8'
    options.compilerArgs += "-parameters"
}

compileJava.options.encoding = 'UTF-8'

tasks.withType(JavaCompile) {
    options.encoding = 'UTF-8'
}

repositories {
    jcenter()
    mavenCentral()
}

buildscript {
    repositories {
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.0-M4'
        classpath 'io.qameta.allure:allure-gradle:2.3'
    }
}

  allure {
    aspectjweaver = true
    autoconfigure = true
    version = '2.1.1'
}

  configurations {
    agent
  }

  dependencies {
    // JUnit5
    compile("org.junit.jupiter:junit-jupiter-api:${junitJupiterVersion}")
    compile("org.junit.jupiter:junit-jupiter-engine:${junitJupiterVersion}")

    // Selenide
    compile("com.codeborne:selenide:${selenideVersion}") {
        exclude group: 'junit'
    }

    // Allure
    agent 'org.aspectj:aspectjweaver:1.8.10'
    compile 'ru.yandex.qatools.allure:allure-junit-adaptor:1.4.23'
    compile 'io.qameta.allure:allure-junit5:2.0-BETA6'
}

    junitPlatform {
platformVersion = "1.0.0-M5"
enableStandardTestTask = true
}

task runJupiter(type: JavaExec) {
jvmArgs '-ea'
jvmArgs "-javaagent:${configurations.agent.singleFile}"
classpath = project.sourceSets.test.runtimeClasspath
main 'org.junit.platform.console.ConsoleLauncher'
args '--scan-class-path'
args "--reports-dir=${buildDir}/allure-results"

finalizedBy 'allureReport'
}

test.dependsOn runJupiter

测试成功完成并自动创建三个文件夹:

{projectDir}\allure-results 带有 .json 文件

{projectDir}\build\test-results\junit-platform 与 TEST-junit-jupiter.xml 文件

{projectDir}\build\reports\allure-report

我尝试通过 allure 命令行 (CLI) 在本地打开 .json 和 .xml 结果。魅力报告已打开,但为空白: this is a report view

我想我在 gradle 依赖项中犯了错误。我很困惑 JUnit5+Allure2+Gradle+Selenide+Java8 应该使用哪些库和版本?

【问题讨论】:

  • 你使用什么 Allure 命令行命令来查看报告?

标签: gradle allure junit5


【解决方案1】:

JUnit Platform Gradle 插件当前不使用test 任务(它需要在 Gradle 核心中进行更改才能这样做)。因此,test.doFirst {...} 之类的东西是行不通的。

您应该能够创建自己的任务来运行ConsoleLauncher 并在其中添加JVM 代理,而不是使用插件。示例见https://stackoverflow.com/a/43512503/6327046

【讨论】:

  • 您在第一句话中指的是哪个 Gradle 插件?
  • 它对我有用。非常感谢。我写了这个:tasks.withType(JavaExec) { if (it.name == 'junitPlatformTest') { doFirst { jvmArgs "-javaagent:${configurations.agent.singleFile}" } finalizedBy 'allureReport' }
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-07-15
  • 2016-05-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-01-23
相关资源
最近更新 更多