From 63f0c62559f30e07d9c4fe1045dd6cc15ae596f6 Mon Sep 17 00:00:00 2001 From: Pavlo Shevchenko Date: Tue, 16 Jul 2024 09:33:06 +0200 Subject: [PATCH] Fix assertions on parameterized test names for older Gradle versions Signed-off-by: Pavlo Shevchenko --- .../TestNGViaJUnitEngineFuncTest.groovy | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/plugin/src/test/groovy/org/gradle/testretry/testframework/TestNGViaJUnitEngineFuncTest.groovy b/plugin/src/test/groovy/org/gradle/testretry/testframework/TestNGViaJUnitEngineFuncTest.groovy index 41e637b2..e6aa7f89 100644 --- a/plugin/src/test/groovy/org/gradle/testretry/testframework/TestNGViaJUnitEngineFuncTest.groovy +++ b/plugin/src/test/groovy/org/gradle/testretry/testframework/TestNGViaJUnitEngineFuncTest.groovy @@ -32,7 +32,10 @@ class TestNGViaJUnitEngineFuncTest extends BaseTestNGFuncTest { private static final EnumSet CLASS_LIFECYCLE_METHODS = EnumSet.of(BEFORE_CLASS, BEFORE_METHOD, AFTER_METHOD) private static final GradleVersion GRADLE_5_0 = GradleVersion.version("5.0") - private static final GradleVersion GRADLE_5_4_1 = GradleVersion.version("5.4.1") + private static final GradleVersion GRADLE_6_1 = GradleVersion.version("6.1") + private static final GradleVersion GRADLE_7_0 = GradleVersion.version("7.0") + private static final GradleVersion GRADLE_7_6_4 = GradleVersion.version("7.6.4") + private static final GradleVersion GRADLE_8_1 = GradleVersion.version("8.1") def setup() { buildFile << """ @@ -55,9 +58,12 @@ class TestNGViaJUnitEngineFuncTest extends BaseTestNGFuncTest { @Override String reportedParameterizedMethodName(String gradleVersion, String methodName, String paramType, int invocationNumber, @Nullable String paramValueRepresentation) { - GradleVersion.version(gradleVersion) > GRADLE_5_4_1 - ? "${methodName}(${paramType}) > [${invocationNumber}] ${paramValueRepresentation ?: ''}" - : "${methodName}(${paramType})[${invocationNumber}]" + switch (GradleVersion.version(gradleVersion)) { + case { it < GRADLE_6_1 }: return "${methodName}(${paramType})[${invocationNumber}]" + case { it < GRADLE_7_0 }: return "[${invocationNumber}] ${paramValueRepresentation ?: ''}" + case { it < GRADLE_8_1 && it != GRADLE_7_6_4 }: return "${methodName}(${paramType})[${invocationNumber}]" + default: return "${methodName}(${paramType}) > [${invocationNumber}] ${paramValueRepresentation ?: ''}" + } } @Override