sm testng: use initial invocation number so rerun would pick correct failure after rerun failed

This commit is contained in:
Anna Kozlova
2015-04-15 20:07:13 +02:00
parent e145aa66ee
commit 2b53c54026
2 changed files with 6 additions and 8 deletions
@@ -73,8 +73,8 @@ public class IDEARemoteTestNG extends TestNG {
final HashMap<String, String> map = new HashMap<String, String>();
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 {
@@ -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<Integer> invocationNumbers = result.getMethod().getInvocationNumbers();
methodName += "[" + parameters[0].toString() + " (" + INVOCATION_NUMBER +
(invocationNumbers.isEmpty() ? myInvocationCount : invocationNumbers.get(myInvocationCount)) + ")" + "]";
if (changeCount) {
myInvocationCount++;
}