diff --git a/.github/renovate.json5 b/.github/renovate.json5 index b0c3e37a1e..96d498bc77 100644 --- a/.github/renovate.json5 +++ b/.github/renovate.json5 @@ -25,6 +25,16 @@ matchCurrentValue: "/^5\\./", allowedVersions: "(,6.0)" }, + { + matchPackageNames: ["/^org.junit:/"], + matchCurrentValue: "/^5\\./", + allowedVersions: "(,6.0)" + }, + { + matchPackageNames: ["/^org.junit:/"], + matchCurrentValue: "/^6\\./", + allowedVersions: "(,7.0)" + }, { matchPackageNames: ["/^org.mockito:/"], matchCurrentValue: "/^4\\./", diff --git a/build.gradle b/build.gradle index cd8e3cc1a7..8449648a53 100644 --- a/build.gradle +++ b/build.gradle @@ -165,7 +165,7 @@ subprojects { dependencies { api platform(projects.spockBom) implementation(project.name == "spock-gradle" ? [] : groovylibs.groovy) - testImplementation(platform(libs.junit.bom)) + testImplementation(platform(libs.junit5.bom)) testImplementation(libs.junit.platform.launcher) } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 3c52794e75..2800baade4 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -5,7 +5,8 @@ groovy3 = '3.0.25' groovy4 = '4.0.29' groovy5 = '5.0.2' jacoco = '0.8.14' -junit = '5.14.1' +junit5 = '5.14.1' +junit6 = '6.0.1' # The VersionRange used by OSGi to check compatibility with JUnit Platform. junitPlatformVersionRange = "[1.12,7)" asm = '9.9' @@ -32,7 +33,8 @@ mockito5 = { module = "org.mockito:mockito-core", version.ref = "mockito5" } objenesis = "org.objenesis:objenesis:3.4" # 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 jacoco-agent = { module = "org.jacoco:org.jacoco.agent", version.ref = "jacoco" } -junit-bom = { module = "org.junit:junit-bom", version.ref = "junit" } +junit5-bom = { module = "org.junit:junit-bom", version.ref = "junit5" } +junit6-bom = { module = "org.junit:junit-bom", version.ref = "junit6" } # to omit the version we have to use this syntax, the version is managed by the junit-bom junit-jupiter.module = "org.junit.jupiter:junit-jupiter" junit-platform-console.module = "org.junit.platform:junit-platform-console" diff --git a/spock-core/core.gradle b/spock-core/core.gradle index 25af1095d2..f53e87469e 100644 --- a/spock-core/core.gradle +++ b/spock-core/core.gradle @@ -22,7 +22,7 @@ configurations { dependencies { api groovylibs.groovy // easiest way to add Groovy dependency to POM - api platform(libs.junit.bom) + api platform(libs.junit5.bom) api 'org.junit.platform:junit-platform-engine' api libs.hamcrest if (variant == 2.5) { diff --git a/spock-spring/boot2-test/boot2-test.gradle b/spock-spring/boot2-test/boot2-test.gradle index 876e864a3c..20ec289dce 100644 --- a/spock-spring/boot2-test/boot2-test.gradle +++ b/spock-spring/boot2-test/boot2-test.gradle @@ -32,7 +32,7 @@ dependencyManagement { } // Spring dependency management downgrades the jupiter version to 5.7.2 otherwise -ext['junit-jupiter.version'] = libs.versions.junit.get() +ext['junit-jupiter.version'] = libs.versions.junit5.get() dependencies { implementation "org.springframework.boot:spring-boot-starter-data-jpa" diff --git a/spock-spring/boot3-test/boot3-test.gradle b/spock-spring/boot3-test/boot3-test.gradle index cb8f47b8b1..c130fba17e 100644 --- a/spock-spring/boot3-test/boot3-test.gradle +++ b/spock-spring/boot3-test/boot3-test.gradle @@ -20,7 +20,7 @@ plugins { } // Spring dependency management downgrades the jupiter version to 5.7.2 otherwise -ext['junit-jupiter.version'] = libs.versions.junit.get() +ext['junit-jupiter.version'] = libs.versions.junit5.get() java { toolchain { diff --git a/spock-testkit/testkit.gradle b/spock-testkit/testkit.gradle index 3d4910d066..4269dddc9a 100644 --- a/spock-testkit/testkit.gradle +++ b/spock-testkit/testkit.gradle @@ -1,24 +1,19 @@ -ext.displayName = "Spock Framework - Temp Specs for Core Module" +plugins { + id 'jvm-test-suite' +} -//configurations { -// junit -//} +ext.displayName = "Spock Framework - Spock TestKit Specs for Core Module" dependencies { api projects.spockCore - testRuntimeOnly libs.asm - testRuntimeOnly libs.bytebuddy - testRuntimeOnly libs.cglib - testRuntimeOnly libs.objenesis - testRuntimeOnly libs.h2database testRuntimeOnly libs.junit.platform.console - testImplementation libs.junit.platform.testkit + testImplementation libs.junit.platform.testkit testImplementation libs.junit.jupiter } -tasks.named("test", Test) { +tasks.withType(Test).configureEach { reports.junitXml.required = true reports.html.required = false @@ -43,3 +38,31 @@ tasks.register("consoleLauncherTest", JavaExec) { args("--reports-dir", reportsDir) // systemProperty("java.util.logging.manager", "org.apache.logging.log4j.jul.LogManager") } + + +if (javaVersion >= 17) { + testing { + suites { + junit6Test(JvmTestSuite) { + useJUnitJupiter(libs.versions.junit6) + sources { + groovy { + srcDirs = ['src/test/groovy'] + } + } + + dependencies { + implementation projects.spockCore + + implementation platform(libs.junit6.bom) + implementation libs.junit.platform.testkit + implementation libs.junit.jupiter + } + } + } + } + + tasks.named('check') { + dependsOn(testing.suites.junit6Test) + } +}