From 2b53c5402672c27f00c2a75b15750ec9c635bfb0 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Wed, 15 Apr 2015 15:26:33 +0200 Subject: [PATCH] sm testng: use initial invocation number so rerun would pick correct failure after rerun failed --- plugins/testng_rt/src/org/testng/IDEARemoteTestNG.java | 4 ++-- .../src/org/testng/IDEATestNGRemoteListener.java | 10 ++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/plugins/testng_rt/src/org/testng/IDEARemoteTestNG.java b/plugins/testng_rt/src/org/testng/IDEARemoteTestNG.java index cb55ecda63aa..a0a7d064eedb 100644 --- a/plugins/testng_rt/src/org/testng/IDEARemoteTestNG.java +++ b/plugins/testng_rt/src/org/testng/IDEARemoteTestNG.java @@ -73,8 +73,8 @@ public class IDEARemoteTestNG extends TestNG { final HashMap map = new HashMap(); map.put("count", String.valueOf(testCount)); System.out.println(ServiceMessage.asString("testCount", map)); - addListener((ISuiteListener) new IDEATestNGRemoteListener(myParam)); - addListener((ITestListener) new IDEATestNGRemoteListener(myParam)); + addListener((ISuiteListener) new IDEATestNGRemoteListener()); + addListener((ITestListener) new IDEATestNGRemoteListener()); super.run(); } else { diff --git a/plugins/testng_rt/src/org/testng/IDEATestNGRemoteListener.java b/plugins/testng_rt/src/org/testng/IDEATestNGRemoteListener.java index 8aa1176d245a..06a202dd9d11 100644 --- a/plugins/testng_rt/src/org/testng/IDEATestNGRemoteListener.java +++ b/plugins/testng_rt/src/org/testng/IDEATestNGRemoteListener.java @@ -7,6 +7,7 @@ import org.testng.internal.IResultListener; import java.io.PrintWriter; import java.io.StringWriter; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -16,15 +17,10 @@ import java.util.Map; public class IDEATestNGRemoteListener implements ISuiteListener, IResultListener{ public static final String INVOCATION_NUMBER = "invocation number: "; - private final String myParam; private String myCurrentClassName; private String myMethodName; private int myInvocationCount = 0; - public IDEATestNGRemoteListener(String param) { - myParam = param; - } - public void onConfigurationSuccess(ITestResult itr) { //won't be called } @@ -75,7 +71,9 @@ public class IDEATestNGRemoteListener implements ISuiteListener, IResultListener } } if (parameters.length > 0) { - methodName += "[" + parameters[0].toString() + (myParam == null ? (" (" + INVOCATION_NUMBER + myInvocationCount + ")") : "") + "]"; + final List invocationNumbers = result.getMethod().getInvocationNumbers(); + methodName += "[" + parameters[0].toString() + " (" + INVOCATION_NUMBER + + (invocationNumbers.isEmpty() ? myInvocationCount : invocationNumbers.get(myInvocationCount)) + ")" + "]"; if (changeCount) { myInvocationCount++; }