Skip to content

Commit 46ec3ba

Browse files
committed
[SUREFIRE-2152] Leave out suffix of templated tests, for StackTraceWriter
It seems cleaner to strip the suffix of templated tests again here, since it is unrelated to the actual method signature, and might hence just cause confusion in context of a StackTraceWriter.
1 parent a87457b commit 46ec3ba

File tree

1 file changed

+8
-2
lines changed
  • surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform

1 file changed

+8
-2
lines changed

surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/RunListenerAdapter.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,14 @@ private SimpleReportEntry createReportEntry( TestIdentifier testIdentifier,
255255
{
256256
methodText = null;
257257
}
258-
StackTraceWriter stw =
259-
testExecutionResult == null ? null : toStackTraceWriter( className, methodName, testExecutionResult );
258+
String methodNameForSTW = methodName;
259+
if ( methodNameForSTW != null && methodNameForSTW.contains( ")[" ) )
260+
{
261+
// don't pass suffix of templated-tests ("[1] ...") on to STW, as it's not part of the method signature
262+
methodNameForSTW = methodNameForSTW.substring( 0, methodNameForSTW.indexOf( ")[" ) + 1 );
263+
}
264+
StackTraceWriter stw = testExecutionResult == null ? null
265+
: toStackTraceWriter( className, methodNameForSTW, testExecutionResult );
260266
return new SimpleReportEntry( runMode, classMethodIndexer.indexClassMethod( className, methodName ), className,
261267
classText, methodName, methodText, stw, elapsedTime, reason, systemProperties );
262268
}

0 commit comments

Comments
 (0)