Skip to content

Commit

Permalink
Merge pull request #300 from gradle/pshevche/fix-testng-tests
Browse files Browse the repository at this point in the history
Fix assertions on parameterized test names for older Gradle versions
  • Loading branch information
pshevche authored Jul 16, 2024
2 parents f16a751 + 63f0c62 commit 59eb29a
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ class TestNGViaJUnitEngineFuncTest extends BaseTestNGFuncTest {
private static final EnumSet<TestNGLifecycleType> 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 << """
Expand All @@ -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
Expand Down

0 comments on commit 59eb29a

Please sign in to comment.