Skip to content

Commit 1277d93

Browse files
committed
Add junit6-integration test project
This shall ensure the execution with JUnit 6 is possible.
1 parent 88c5b99 commit 1277d93

File tree

7 files changed

+51
-17
lines changed

7 files changed

+51
-17
lines changed

.github/renovate.json5

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@
2525
matchCurrentValue: "/^5\\./",
2626
allowedVersions: "(,6.0)"
2727
},
28+
{
29+
matchPackageNames: ["/^org.junit:/"],
30+
matchCurrentValue: "/^5\\./",
31+
allowedVersions: "(,6.0)"
32+
},
33+
{
34+
matchPackageNames: ["/^org.junit:/"],
35+
matchCurrentValue: "/^6\\./",
36+
allowedVersions: "(,7.0)"
37+
},
2838
{
2939
matchPackageNames: ["/^org.mockito:/"],
3040
matchCurrentValue: "/^4\\./",

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ subprojects {
165165
dependencies {
166166
api platform(projects.spockBom)
167167
implementation(project.name == "spock-gradle" ? [] : groovylibs.groovy)
168-
testImplementation(platform(libs.junit.bom))
168+
testImplementation(platform(libs.junit5.bom))
169169
testImplementation(libs.junit.platform.launcher)
170170
}
171171

gradle/libs.versions.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ groovy3 = '3.0.25'
55
groovy4 = '4.0.29'
66
groovy5 = '5.0.2'
77
jacoco = '0.8.14'
8-
junit = '5.14.0'
8+
junit5 = '5.14.0'
9+
junit6 = '6.0.0'
910
# The VersionRange used by OSGi to check compatibility with JUnit Platform.
1011
junitPlatformVersionRange = "[1.12,7)"
1112
asm = '9.9'
@@ -32,7 +33,8 @@ mockito5 = { module = "org.mockito:mockito-core", version.ref = "mockito5" }
3233
objenesis = "org.objenesis:objenesis:3.4"
3334
# This needs a classifier, but it has to be specified on the usage end https://melix.github.io/blog/2021/03/version-catalogs-faq.html#_why_can_t_i_use_excludes_or_classifiers
3435
jacoco-agent = { module = "org.jacoco:org.jacoco.agent", version.ref = "jacoco" }
35-
junit-bom = { module = "org.junit:junit-bom", version.ref = "junit" }
36+
junit5-bom = { module = "org.junit:junit-bom", version.ref = "junit5" }
37+
junit6-bom = { module = "org.junit:junit-bom", version.ref = "junit6" }
3638
# to omit the version we have to use this syntax, the version is managed by the junit-bom
3739
junit-jupiter.module = "org.junit.jupiter:junit-jupiter"
3840
junit-platform-console.module = "org.junit.platform:junit-platform-console"

spock-core/core.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ configurations {
2222

2323
dependencies {
2424
api groovylibs.groovy // easiest way to add Groovy dependency to POM
25-
api platform(libs.junit.bom)
25+
api platform(libs.junit5.bom)
2626
api 'org.junit.platform:junit-platform-engine'
2727
api libs.hamcrest
2828
if (variant == 2.5) {

spock-spring/boot2-test/boot2-test.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ dependencyManagement {
3232
}
3333

3434
// Spring dependency management downgrades the jupiter version to 5.7.2 otherwise
35-
ext['junit-jupiter.version'] = libs.versions.junit.get()
35+
ext['junit-jupiter.version'] = libs.versions.junit5.get()
3636

3737
dependencies {
3838
implementation "org.springframework.boot:spring-boot-starter-data-jpa"

spock-spring/boot3-test/boot3-test.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ plugins {
2020
}
2121

2222
// Spring dependency management downgrades the jupiter version to 5.7.2 otherwise
23-
ext['junit-jupiter.version'] = libs.versions.junit.get()
23+
ext['junit-jupiter.version'] = libs.versions.junit5.get()
2424

2525
java {
2626
toolchain {

spock-testkit/testkit.gradle

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,19 @@
1-
ext.displayName = "Spock Framework - Temp Specs for Core Module"
1+
plugins {
2+
id 'jvm-test-suite'
3+
}
24

3-
//configurations {
4-
// junit
5-
//}
5+
ext.displayName = "Spock Framework - Spock TestKit Specs for Core Module"
66

77
dependencies {
88
api projects.spockCore
99

10-
testRuntimeOnly libs.asm
11-
testRuntimeOnly libs.bytebuddy
12-
testRuntimeOnly libs.cglib
13-
testRuntimeOnly libs.objenesis
14-
testRuntimeOnly libs.h2database
1510
testRuntimeOnly libs.junit.platform.console
16-
testImplementation libs.junit.platform.testkit
1711

12+
testImplementation libs.junit.platform.testkit
1813
testImplementation libs.junit.jupiter
1914
}
2015

21-
tasks.named("test", Test) {
16+
tasks.withType(Test).configureEach {
2217
reports.junitXml.required = true
2318
reports.html.required = false
2419

@@ -43,3 +38,30 @@ tasks.register("consoleLauncherTest", JavaExec) {
4338
args("--reports-dir", reportsDir)
4439
// systemProperty("java.util.logging.manager", "org.apache.logging.log4j.jul.LogManager")
4540
}
41+
42+
43+
if (javaVersion >= 17) {
44+
testing {
45+
suites {
46+
junit6Test(JvmTestSuite) {
47+
useJUnitJupiter(libs.versions.junit6)
48+
sources {
49+
groovy {
50+
srcDirs = ['src/test/groovy']
51+
}
52+
}
53+
54+
dependencies {
55+
implementation platform(libs.junit6.bom)
56+
implementation projects.spockCore
57+
implementation libs.junit.platform.testkit
58+
implementation libs.junit.jupiter
59+
}
60+
}
61+
}
62+
}
63+
64+
tasks.named('check') {
65+
dependsOn(testing.suites.junit6Test)
66+
}
67+
}

0 commit comments

Comments
 (0)