标题翻译
gradle 6.1 + JUnit 5: integration tests do not generate xml or html reports
问题
我在多项目中有以下的 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 报告?
英文翻译
I have the following build.gradle in multi-project:
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
}
When I run gradle integrationTest, integration tests get invoked, but only binary report is generated in:
build/integration-test-results/binary/integrationTest
No XML or HTML results! Seems that JUnit 5 changed something radically from JUnit 4.
How can I get XML or HTML reports?
专注分享java语言的经验与见解,让所有开发者获益!
评论