gradle 6.1 + JUnit 5:集成测试不会生成xml或html报告

时间:2020-01-30 11:48:09

标签: java gradle junit5

我在多项目中具有以下build.gradle:

plugins {
    id 'idea'
    id 'eclipse'
    id 'java'
}

sourceSets {
    integrationTest {
        java {
            compileClasspath += main.output + test.output
            runtimeClasspath += main.output + test.output
            srcDir file('src/integration-test/java')
        }
        resources.srcDir file('src/integration-test/resources')
    }
}

configurations {
    integrationTestImplementation.extendsFrom testImplementation
    integrationTestCompile.extendsFrom testCompile
    integrationTestRuntime.extendsFrom testRuntime
}

test {
    useJUnitPlatform()
    minHeapSize = "2048m"
    maxHeapSize = "6144m"
    reports {
        junitXml.enabled = true
        html.enabled = true
    }
}

dependencies {
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.0'
    testRuntime 'org.junit.jupiter:junit-jupiter-engine:5.6.0'
    testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: '5.6.0'

    integrationTestRuntime 'org.junit.jupiter:junit-jupiter-engine:5.6.0'

    compile "org.seleniumhq.selenium:selenium-java:3.141.59"
}

task integrationTest(type: Test) {
    useJUnitPlatform()

    minHeapSize = "10g"
    maxHeapSize = "10g"

    outputs.upToDateWhen { false }

    group = LifecycleBasePlugin.VERIFICATION_GROUP
    description = 'Runs the integration tests.'

    testClassesDirs = sourceSets.integrationTest.output.classesDirs
    classpath = sourceSets.integrationTest.runtimeClasspath

    binResultsDir = file("$buildDir/integration-test-results/binary/integrationTest")

    reports {
        html.enabled = true
        junitXml.enabled = true
        html.destination = file("$buildDir/integration-test-results")
        junitXml.destination = file("$buildDir/integration-test-results")
    }

    mustRunAfter tasks.test
}

当我运行gradle integrationTest时,将调用集成测试,但是在以下位置仅生成二进制报告:

build / integration-test-results / binary / integrationTest

没有XML或HTML结果!似乎JUnit 5与JUnit 4发生了根本性的变化。 如何获取XML或HTML报告?

0 个答案:

没有答案