Skip to content

Commit 7d1d355

Browse files
authored
Upgrade to TestNG 7.5 (#58)
1 parent ec18d77 commit 7d1d355

File tree

5 files changed

+23
-24
lines changed

5 files changed

+23
-24
lines changed

java8Deps.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ sourceSets {
2525

2626
dependencies {
2727
constraints {
28-
api 'org.testng:testng:7.3.0'
28+
api 'org.testng:testng:7.5'
2929
api 'org.apache.ant:ant:1.10.11'
3030
}
3131
api 'org.testng:testng'

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@
297297
<id>java8</id>
298298
<properties>
299299
<maven.compiler.release>8</maven.compiler.release>
300-
<testng.version>7.3.0</testng.version>
300+
<testng.version>7.5</testng.version>
301301
<ant.version>1.10.11</ant.version>
302302
</properties>
303303
<dependencyManagement>

src/main-j7/java/com/nordstrom/automation/testng/VersionUtility.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package com.nordstrom.automation.testng;
22

33
import org.testng.IRetryAnalyzer;
4+
import org.testng.ITestNGMethod;
45
import org.testng.ITestResult;
6+
import org.testng.Reporter;
57
import org.testng.annotations.ITestAnnotation;
68
import org.testng.internal.TestResult;
79

@@ -16,4 +18,11 @@ public static ITestResult newEmptyTestResult() {
1618
return new TestResult();
1719
}
1820

21+
public static Class<? extends IRetryAnalyzer> getRetryAnalyzer() {
22+
ITestResult testResult = Reporter.getCurrentTestResult();
23+
ITestNGMethod method = testResult.getMethod();
24+
IRetryAnalyzer retryAnalyzer = method.getRetryAnalyzer();
25+
return (retryAnalyzer != null) ? retryAnalyzer.getClass() : null;
26+
}
27+
1928
}

src/main-j8/java/com/nordstrom/automation/testng/VersionUtility.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package com.nordstrom.automation.testng;
22

33
import org.testng.IRetryAnalyzer;
4+
import org.testng.ITestNGMethod;
45
import org.testng.ITestResult;
6+
import org.testng.Reporter;
57
import org.testng.annotations.ITestAnnotation;
68
import org.testng.internal.TestResult;
79
import org.testng.internal.annotations.DisabledRetryAnalyzer;
@@ -17,4 +19,11 @@ public static ITestResult newEmptyTestResult() {
1719
return TestResult.newEmptyTestResult();
1820
}
1921

22+
public static Class<? extends IRetryAnalyzer> getRetryAnalyzer() {
23+
ITestResult testResult = Reporter.getCurrentTestResult();
24+
ITestNGMethod method = testResult.getMethod();
25+
Class<? extends IRetryAnalyzer> clazz = method.getRetryAnalyzerClass();
26+
return (clazz != DisabledRetryAnalyzer.class) ? clazz : null;
27+
}
28+
2029
}

src/test/java/com/nordstrom/automation/testng/RetryAnalyzerCheck.java

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
import static org.testng.Assert.assertNotEquals;
66

77
import org.testng.IRetryAnalyzer;
8-
import org.testng.ITestNGMethod;
98
import org.testng.ITestResult;
10-
import org.testng.Reporter;
119
import org.testng.annotations.BeforeClass;
1210
import org.testng.annotations.Test;
1311

@@ -22,36 +20,19 @@ public void beforeClass() {
2220

2321
@Test
2422
public void retryAnalyzerUnspecified() {
25-
unspecified = getRetryAnalyzer();
23+
unspecified = VersionUtility.getRetryAnalyzer();
2624
assertNotEquals(unspecified, Placeholder.class);
2725
}
2826

2927
@Test(retryAnalyzer = TestAnalyzer.class)
3028
public void retryAnalyzerIsSpecified() {
31-
assertEquals(getRetryAnalyzer(), TestAnalyzer.class);
29+
assertEquals(VersionUtility.getRetryAnalyzer(), TestAnalyzer.class);
3230
}
3331

3432
@Test
3533
@NoRetry
3634
public void retryIsDisabledForThisTest() {
37-
assertNull(getRetryAnalyzer());
38-
}
39-
40-
@SuppressWarnings("deprecation")
41-
private static Class<? extends IRetryAnalyzer> getRetryAnalyzer() {
42-
ITestResult testResult = Reporter.getCurrentTestResult();
43-
ITestNGMethod method = testResult.getMethod();
44-
IRetryAnalyzer retryAnalyzer = method.getRetryAnalyzer();
45-
// if retry analyzer defined
46-
if (retryAnalyzer != null) {
47-
// get class of retry analyzer
48-
Class<? extends IRetryAnalyzer> clazz = retryAnalyzer.getClass();
49-
// if not the default retry analyzer injected by TestNG 7+
50-
if ( ! "org.testng.internal.annotations.DisabledRetryAnalyzer".equals(clazz.getName())) {
51-
return clazz;
52-
}
53-
}
54-
return null;
35+
assertNull(VersionUtility.getRetryAnalyzer());
5536
}
5637

5738
public static class TestAnalyzer implements IRetryAnalyzer {

0 commit comments

Comments
 (0)