feat(run): show each invocation of a parameterized test in the Run window (#7099)

The JUnit runner and the Gradle test init script report an invocation of a parameterized, repeated or dynamic test with its display name, and the JVM parser puts it under its method node with its own status, output and stack trace; the method shows the aggregate. Rerunning a failed invocation reruns its method.

Fixes #7046
Цей коміт міститься в:
l0ng-ai authored and GitHub committed 2026-12-01 03:06:11 +08:00
1 джерело 81c95b2ab7
коміт b5e89aace0
8 files changed
+76 -20

No files matched your search

+2 -1
Переглянути файл
@@ -51,7 +51,8 @@ with tempfile.TemporaryDirectory() as scratch:
"##teamcity[testFailed name='fails' className='sample.SampleTest' message='org.opentest4j.AssertionFailedError: it|'s wrong ==> expected: <1> but was: <2>'",
"##teamcity[testIgnored name='disabled' className='sample.SampleTest'",
"##teamcity[testIgnored name='aborted' className='sample.SampleTest']",
"##teamcity[testFailed name='parameterized' className='sample.SampleTest'",
"##teamcity[testStarted name='parameterized' className='sample.SampleTest' invocation='|[1|] 1']",
"##teamcity[testFailed name='parameterized' className='sample.SampleTest' invocation='|[2|] 2'",
"##teamcity[testFinished name='nested' className='sample.SampleTest$Inner' duration=",
"7 tests completed, 2 failed, 2 skipped",
]
Бінарний файл не відображається.
+14 -7
Переглянути файл
@@ -153,18 +153,25 @@ final class PlatformRunner implements TestExecutionListener {
for (Output o : outputs) o.flushLines(true);
}
/** `name='method' className='a.B$Nested'`, the method and class of the test or its closest source. */
/**
* `name='method' className='a.B$Nested'`, the method and class of the test or its closest source;
* an invocation of a parameterized, repeated or dynamic test adds `invocation='[1] a'`, its display name.
*/
private String id(TestIdentifier id) {
// The outermost method of the chain: the test itself, or the method container of its invocations.
TestIdentifier method = null;
for (TestIdentifier at = id; at != null; at = plan.getParent(at).orElse(null)) {
TestSource source = at.getSource().orElse(null);
if (source instanceof MethodSource) {
MethodSource m = (MethodSource) source;
return Reporter.attr("name", m.getMethodName()) + Reporter.attr("className", m.getClassName());
}
if (source instanceof ClassSource)
if (source instanceof MethodSource) method = at;
else if (method != null) break;
else if (source instanceof ClassSource)
return Reporter.attr("name", id.getLegacyReportingName()) + Reporter.attr("className", ((ClassSource) source).getClassName());
}
return Reporter.attr("name", id.getLegacyReportingName()) + Reporter.attr("className", id.getDisplayName());
if (method == null)
return Reporter.attr("name", id.getLegacyReportingName()) + Reporter.attr("className", id.getDisplayName());
MethodSource m = (MethodSource) method.getSource().get();
String own = Reporter.attr("name", m.getMethodName()) + Reporter.attr("className", m.getClassName());
return method == id ? own : own + Reporter.attr("invocation", id.getDisplayName());
}
private Optional<String> className(TestIdentifier id) {