Skip to content

Commit

Permalink
Set testing framework versions in build script, and bump them to the …
Browse files Browse the repository at this point in the history
…latest versions (#337)


---------

Signed-off-by: Jean Gauthier <[email protected]>
  • Loading branch information
jean-andre-gauthier authored Oct 29, 2024
1 parent f1edf99 commit a6ec659
Show file tree
Hide file tree
Showing 13 changed files with 112 additions and 27 deletions.
17 changes: 15 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
[versions]
asmVersion = "9.7.1"
spockframework = "2.3-groovy-3.0"
junit4 = "4.13.2"
junit5Jupiter = "5.11.2"
junitPlatformLauncher = "1.11.2"
mockito = "4.11.0"
spock1 = "1.3-groovy-2.5"
spock2 = "2.3-groovy-3.0"
testNg = "5.11.2"

[libraries]
spock-bom = { module = "org.spockframework:spock-bom", version.ref = "spockframework" }
spock-bom = { module = "org.spockframework:spock-bom", version.ref = "spock2" }
spock-core.module = "org.spockframework:spock-core"
spock-junit4.module = "org.spockframework:spock-junit4"
nekohtml = "net.sourceforge.nekohtml:nekohtml:1.9.22"
asm = { module = "org.ow2.asm:asm", version.ref = "asmVersion" }
jetbrains-annotations = "org.jetbrains:annotations:26.0.1"
codenarc = "org.codenarc:CodeNarc:3.5.0-groovy-4.0"
junit4 = { module = "junit:junit", version.ref = "junit4" }
junit5-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit5Jupiter" }
junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher", version.ref = "junitPlatformLauncher" }
mockito = { module = "org.mockito:mockito-core", version.ref = "mockito" }
spock1 = { module = "org.spockframework:spock-core", version.ref = "spock1" }
spock2 = { module = "org.spockframework:spock-core", version.ref = "spock2" }
testNg = { module = "org.testng:testng", version.ref = "testNg" }
7 changes: 7 additions & 0 deletions plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@ tasks.test {
GradleVersionsCommandLineArgumentProvider.PROPERTY_NAME,
project.findProperty("testedGradleVersion") ?: gradle.gradleVersion
)
systemProperty("junit4Version", libs.versions.junit4.get())
systemProperty("junit5Version", libs.versions.junit5Jupiter.get())
systemProperty("junitPlatformLauncherVersion", libs.versions.junitPlatformLauncher.get())
systemProperty("mockitoVersion", libs.versions.mockito.get())
systemProperty("spock1Version", libs.versions.spock1.get())
systemProperty("spock2Version", libs.versions.spock2.get())
systemProperty("testNgVersion", libs.versions.testNg.get())
}

listOf(5, 6, 7, 8).map { gradleMajorVersion ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import spock.lang.Specification

import java.lang.management.ManagementFactory

abstract class AbstractPluginFuncTest extends Specification {
abstract class AbstractPluginFuncTest extends Specification implements TestFrameworkVersionData {

public static final List<String> GRADLE_VERSIONS_UNDER_TEST = gradleVersionsUnderTest()

Expand Down Expand Up @@ -140,7 +140,11 @@ abstract class AbstractPluginFuncTest extends Specification {
}

protected String buildConfiguration() {
return 'dependencies { testImplementation "junit:junit:4.13.2" }'
return """
dependencies {
testImplementation "${junit4Dependency()}"
}
"""
}

static String flakyAssert(String id = "id", int failures = 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,12 @@ import org.gradle.util.GradleVersion
class TestDryRunFuncTest extends AbstractGeneralPluginFuncTest {

private static final GradleVersion GRADLE_8_3 = GradleVersion.version("8.3")
private static final String MIN_JUPITER_VERSION_DRY_RUN = "5.10.0-RC1"
private static final String MIN_PLATFORM_VERSION_DRY_RUN = "1.10.0-RC1"

@Override
protected String buildConfiguration() {
return """dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter:$MIN_JUPITER_VERSION_DRY_RUN'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher:$MIN_PLATFORM_VERSION_DRY_RUN'
testImplementation '${jupiterDependency()}'
testRuntimeOnly '${junitPlatformLauncherDependency()}'
}"""
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright 2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.gradle.testretry

trait TestFrameworkVersionData {

String junit4Dependency() {
"junit:junit:" + System.getProperty("junit4Version")
}

String jupiterDependency() {
"org.junit.jupiter:junit-jupiter:" + System.getProperty("junit5Version")
}

String jupiterApiDependency() {
"org.junit.jupiter:junit-jupiter-api:" + System.getProperty("junit5Version")
}

String jupiterEngineDependency() {
"org.junit.jupiter:junit-jupiter-engine:" + System.getProperty("junit5Version")
}

String jupiterParamsDependency() {
"org.junit.jupiter:junit-jupiter-params:" + System.getProperty("junit5Version")
}

String junitVintageEngineDependency() {
"org.junit.vintage:junit-vintage-engine:" + System.getProperty("junit5Version")
}

String junitPlatformLauncherDependency() {
"org.junit.platform:junit-platform-launcher:" + System.getProperty("junitPlatformLauncherVersion")
}

String mockitoDependency() {
"org.mockito:mockito-core:" + System.getProperty("mockitoVersion")
}

String spock1Dependency() {
"org.spockframework:spock-core:" + System.getProperty("spock1Version")
}

String spock2Dependency() {
"org.spockframework:spock-core:" + System.getProperty("spock2Version")
}

String testNgDependency() {
"org.testng:testng:" + System.getProperty("testNgVersion")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ abstract class BaseTestNGFuncTest extends AbstractFrameworkFuncTest {
protected String buildConfiguration() {
return """
dependencies {
testImplementation 'org.testng:testng:7.5'
testImplementation '${testNgDependency()}'
}
test {
useTestNG()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ class JUnit4ViaJUnitVintageFuncTest extends JUnit4FuncTest {
}

protected String buildConfiguration() {
return '''
return """
dependencies {
testImplementation "junit:junit:4.13.2"
testImplementation "org.junit.jupiter:junit-jupiter-api:5.9.2"
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:5.9.2"
testImplementation "${junit4Dependency()}"
testImplementation "${jupiterApiDependency()}"
testRuntimeOnly "${junitVintageEngineDependency()}"
}
test {
useJUnitPlatform()
}
'''
"""
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -726,9 +726,9 @@ class JUnit5FuncTest extends AbstractFrameworkFuncTest {
protected String buildConfiguration() {
return """
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.2'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.9.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.2'
testImplementation '${jupiterApiDependency()}'
testImplementation '${jupiterParamsDependency()}'
testRuntimeOnly '${jupiterEngineDependency()}'
}
test {
useJUnitPlatform()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class MockitoFuncTest extends AbstractFrameworkFuncTest {
protected String buildConfiguration() {
super.buildConfiguration() + """
dependencies {
testImplementation("org.mockito:mockito-core:3.11.2")
testImplementation("${mockitoDependency()}")
}
"""
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Spock2FuncTest extends SpockBaseJunit5FuncTest {
protected String buildConfiguration() {
return """
dependencies {
implementation 'org.spockframework:spock-core:2.3-groovy-3.0'
implementation '${spock2Dependency()}'
}
test {
useJUnitPlatform()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1220,7 +1220,7 @@ abstract class SpockBaseFuncTest extends AbstractFrameworkFuncTest {
where:
a << [1, 2]
}


def successfulTest() {
expect:
Expand Down Expand Up @@ -1264,7 +1264,7 @@ abstract class SpockBaseFuncTest extends AbstractFrameworkFuncTest {
where:
a << [1, 2]
}


def "test for c"() {
expect:
Expand Down Expand Up @@ -1308,7 +1308,7 @@ abstract class SpockBaseFuncTest extends AbstractFrameworkFuncTest {
where:
a << [1, 2]
}


def "test for c"() {
expect:
Expand Down Expand Up @@ -1337,7 +1337,7 @@ abstract class SpockBaseFuncTest extends AbstractFrameworkFuncTest {
return """
dependencies {
implementation "org.codehaus.groovy:groovy:2.5.8"
testImplementation "org.spockframework:spock-core:1.3-groovy-2.5"
testImplementation "${spock1Dependency()}"
}
"""
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ abstract class SpockBaseJunit5FuncTest extends SpockBaseFuncTest {
protected String buildConfiguration() {
return """
dependencies {
implementation 'org.spockframework:spock-core:2.3-groovy-3.0'
implementation '${spock2Dependency()}'
}
test {
useJUnitPlatform()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ class SpockViaJUnitVintageFuncTest extends SpockBaseJunit5FuncTest {
return """
dependencies {
implementation "org.codehaus.groovy:groovy:2.5.8"
testImplementation "org.spockframework:spock-core:1.3-groovy-2.5"
testImplementation "org.junit.jupiter:junit-jupiter-api:5.9.2"
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:5.9.2"
testImplementation "${spock1Dependency()}"
testImplementation "${jupiterApiDependency()}"
testRuntimeOnly "${junitVintageEngineDependency()}"
}
test {
Expand Down

0 comments on commit a6ec659

Please sign in to comment.