-
Notifications
You must be signed in to change notification settings - Fork 406
Introduce JUnit5 #2493
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce JUnit5 #2493
Changes from 11 commits
ef49bcb
9cb8598
97473ea
0f9a6af
562c057
36739a8
5eaf9a0
0360f1b
0966391
ded62e9
b0620a9
2dcdb4a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
buildscript { | ||
repositories { | ||
mavenCentral() | ||
} | ||
dependencies { | ||
classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.1' | ||
} | ||
} | ||
|
||
plugins { | ||
id 'java' | ||
id 'application' | ||
|
@@ -11,6 +20,7 @@ plugins { | |
} | ||
|
||
apply from: 'gradle/scripts/yaml.gradle' | ||
apply plugin: 'org.junit.platform.gradle.plugin' | ||
|
||
group = 'triplea' | ||
description = 'TripleA is a free online turn based strategy game and board game engine, similar to such board games as Axis & Allies or Risk.' | ||
|
@@ -49,7 +59,7 @@ sourceSets { | |
java.srcDir 'src/integ_test/java' | ||
resources.srcDir 'src/integ_test/resources' | ||
|
||
compileClasspath = sourceSets.main.output + sourceSets.test.output + configurations.testRuntime | ||
compileClasspath = sourceSets.main.output + sourceSets.test.output + configurations.testRuntime + configurations.junitPlatform | ||
runtimeClasspath = output + compileClasspath | ||
} | ||
} | ||
|
@@ -95,28 +105,22 @@ dependencies { | |
testCompile 'eu.codearte.catch-exception:catch-exception:2.0.0-ALPHA-1' | ||
testCompile 'nl.jqno.equalsverifier:equalsverifier:2.3.3' | ||
testCompile 'org.hamcrest:java-hamcrest:2.0.0.0' | ||
testCompile 'org.mockito:mockito-core:2.10.0' | ||
testCompile 'junit:junit:4.12' | ||
} | ||
|
||
test { | ||
exclude '**/*Tests.class' | ||
testCompile 'org.mockito:mockito-core:2.11.0' | ||
testRuntime 'org.junit.platform:junit-platform-launcher:1.0.1' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Could you please move this down one line so we keep the different configurations grouped together? It's easy to miss the difference between |
||
testCompile 'org.junit.jupiter:junit-jupiter-api:5.0.1' | ||
testRuntime 'org.junit.jupiter:junit-jupiter-engine:5.0.1' | ||
} | ||
|
||
|
||
task integTest(type: Test) { | ||
task integTest(type: JavaExec) { | ||
group = LifecycleBasePlugin.VERIFICATION_GROUP | ||
description = 'Runs the integration tests.' | ||
|
||
testClassesDirs = sourceSets.integTest.output.classesDirs | ||
classpath = sourceSets.integTest.runtimeClasspath | ||
|
||
binResultsDir = file("$buildDir/integration_test_results/binary/integTest") | ||
|
||
reports { | ||
reports.html.destination = file("${reports.html.destination}/$name") | ||
reports.junitXml.destination = file("${reports.junitXml.destination}/$name") | ||
} | ||
main = 'org.junit.platform.console.ConsoleLauncher' | ||
args '--details', 'none' | ||
args "--reports-dir=$project.buildDir/integ-test-results/junit-platform" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: The |
||
args '--scan-classpath' | ||
args '--include-classname', '^.*IntegrationTests?$' | ||
|
||
mustRunAfter tasks.test | ||
} | ||
|
@@ -313,3 +317,23 @@ jacocoTestReport { | |
html.enabled true | ||
} | ||
} | ||
|
||
afterEvaluate { | ||
def junitPlatformTest = tasks.junitPlatformTest | ||
|
||
jacoco { | ||
applyTo(junitPlatformTest) | ||
} | ||
|
||
task jacocoJunit5TestReport(type: JacocoReport) { | ||
executionData junitPlatformTest | ||
sourceSets sourceSets.main | ||
sourceDirectories = files(sourceSets.main.allSource.srcDirs) | ||
classDirectories = files(sourceSets.main.output) | ||
|
||
reports { | ||
xml.enabled true | ||
html.enabled true | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh, but at least the JUnit team is aware of the issue: junit-team/junit5#768. However, it appears to have been pushed back to 5.1 as of 14 hours ago. 😞
Note that there's a workaround listed in the issue, but I'm not sure if it's worth introducing that just to keep
build.gradle
clean.Nit: Pasting the
buildscript
configuration from the JUnit docs introduced mixed tabs/spaces into this file.