From b7d0d8374c94483d412568e62968f1b4bdf9fe36 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Wed, 13 May 2015 21:38:57 +0200 Subject: [PATCH] testng: name different invocations of tests differently as concurrent execution could break protocol otherwise (IDEA-140265) --- .../org/testng/IDEATestNGRemoteListener.java | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/plugins/testng_rt/src/org/testng/IDEATestNGRemoteListener.java b/plugins/testng_rt/src/org/testng/IDEATestNGRemoteListener.java index dbf62b274a17..b4ef4ca15e78 100644 --- a/plugins/testng_rt/src/org/testng/IDEATestNGRemoteListener.java +++ b/plugins/testng_rt/src/org/testng/IDEATestNGRemoteListener.java @@ -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; }