Skip to content

Commit 27febbd

Browse files
committed
[java-driver#755] Fixing issue when skipped exception is treated as failed one.
1 parent 0f3ae37 commit 27febbd

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

driver-core/src/test/java/com/datastax/driver/core/TestListener.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,6 @@ public class TestListener extends TestListenerAdapter implements IInvokedMethodL
4545

4646
@Override
4747
public void onTestFailure(ITestResult tr) {
48-
if (tr.getThrowable() instanceof SkipException) {
49-
// Workaround for testng 6.13.x bug https://github.com/testng-team/testng/issues/1632
50-
// When SkipException thrown from beforeInvocation marks test as FAILED
51-
tr.setStatus(ITestResult.SKIP);
52-
return;
53-
}
5448
long elapsedTime = TimeUnit.NANOSECONDS.toSeconds((System.nanoTime() - start_time));
5549
long testTime = tr.getEndMillis() - tr.getStartMillis();
5650
tr.getThrowable().printStackTrace();
@@ -121,11 +115,15 @@ public void beforeInvocation(IInvokedMethod testMethod, ITestResult testResult)
121115
ConstructorOrMethod constructorOrMethod = testNgMethod.getConstructorOrMethod();
122116

123117
Class<?> clazz = testNgMethod.getInstance().getClass();
124-
if (clazz != null) {
125-
do {
118+
do {
119+
try {
126120
if (scanAnnotatedElement(clazz)) break;
127-
} while (!(clazz = clazz.getSuperclass()).equals(Object.class));
128-
}
121+
} catch (SkipException e) {
122+
// Workaround for testng 6.13.x bug https://github.com/testng-team/testng/issues/1632
123+
// When SkipException thrown from beforeInvocation marks test as FAILED
124+
testResult.setStatus(ITestResult.SKIP);
125+
}
126+
} while (!(clazz = clazz.getSuperclass()).equals(Object.class));
129127
Method method = constructorOrMethod.getMethod();
130128
if (method != null) {
131129
scanAnnotatedElement(method);

0 commit comments

Comments
 (0)