首页 文章

使用Allure2 Junit5 Gradle Selenide时Allure报告为空

提问于
浏览
1

我的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

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

\ allure-results with .json file \ build \ test-results \ _unit-platform with TEST-junit-jupiter.xml file \ build \ reports \ allure-report

我尝试通过诱惑命令行(CLI)在本地打开.json和.xml结果 . 诱惑报告已打开,但它是空白的:this is a report view

我想我在gradle依赖项中的错误 . 我很困惑哪些库和版本应该用于JUnit5 Allure2 Gradle Selenide Java8?

1 回答

  • 1

    JUnit Platform Gradle插件当前不使用 test 任务(它需要在Gradle核心中进行更改才能执行此操作) . 因此, test.doFirst {...} 之类的东西不会起作用 .

    您应该能够创建自己的运行 ConsoleLauncher 的任务并在那里添加JVM代理,而不是使用插件 . 有关示例,请参阅https://stackoverflow.com/a/43512503/6327046 .

相关问题