testng: name different invocations of tests differently as concurrent execution could break protocol otherwise (IDEA-140265)

This commit is contained in:
Anna Kozlova
2015-05-13 22:02:02 +02:00
parent 4e2e4edba0
commit b7d0d8374c
@@ -63,10 +63,21 @@ public class IDEATestNGRemoteListener implements ISuiteListener, IResultListener
invocationCount = myInvocationCount;
myMap.put(result, invocationCount);
}
onTestStart(getTestHierarchy(result), testMethodName, parameters.length > 0 ? "[" + getParamsString(parameters) + "]" : null, invocationCount);
final String paramString = parameters.length > 0 || invocationCount > 0
? "[" + getParamsSpace(invocationCount, parameters) + getParamsString(parameters) + "]"
: null;
onTestStart(getTestHierarchy(result), testMethodName,
paramString, invocationCount);
myInvocationCount++;
}
public static String getParamsSpace(Integer invocationCount, Object[] parameters) {
if (invocationCount > 0) {
return invocationCount + (parameters.length > 0 ? " " : "");
}
return "";
}
public synchronized void onTestSuccess(ITestResult result) {
onTestFinished(getTestMethodNameWithParams(result));
}
@@ -203,11 +214,16 @@ public class IDEATestNGRemoteListener implements ISuiteListener, IResultListener
"\' locationHint=\'java:test://" + escapeName(className + "." + methodName + ( invocationCount >= 0 ? "[" + invocationCount + "]" : "")) + "\']");
}
private static String getTestMethodNameWithParams(ITestResult result) {
private synchronized String getTestMethodNameWithParams(ITestResult result) {
String methodName = getTestMethodName(result);
final Object[] parameters = result.getParameters();
if (parameters.length > 0) {
methodName += "[" + getParamsString(parameters) + "]";
Integer invocationCount = myMap.get(result);
if (parameters.length > 0 || invocationCount != null && invocationCount > 0) {
methodName += "[";
if (invocationCount != null) {
methodName += getParamsSpace(invocationCount, parameters);
}
methodName += getParamsString(parameters) + "]";
}
return methodName;
}