Skip to content

Commit de00ade

Browse files
committed
Revert "Combine PR made by Marc from #1"
This reverts commit eef975b.
1 parent eef975b commit de00ade

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

junit-platform-console/src/main/java/org/junit/platform/console/tasks/ConsoleTestExecutor.java

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ public class ConsoleTestExecutor {
4949
private final TestConsoleOutputOptions outputOptions;
5050
private final Supplier<Launcher> launcherSupplier;
5151

52+
private TestPlan testPlanListeners;
53+
5254
public ConsoleTestExecutor(TestDiscoveryOptions discoveryOptions, TestConsoleOutputOptions outputOptions) {
5355
this(discoveryOptions, outputOptions, LauncherFactory::create);
5456
}
@@ -99,11 +101,12 @@ private TestExecutionSummary executeTests(PrintWriter out, Optional<Path> report
99101
Launcher launcher = launcherSupplier.get();
100102
SummaryGeneratingListener summaryListener = registerListeners(out, reportsDir, launcher);
101103
LauncherDiscoveryRequest discoveryRequest = new DiscoveryRequestCreator().toDiscoveryRequest(discoveryOptions);
102-
TestPlanCapturer testPlanCapturer = new TestPlanCapturer();
103104
launcher.execute(discoveryRequest);
104105
TestExecutionSummary summary = summaryListener.getSummary();
105106
if (summary.getTotalFailureCount() > 0 || outputOptions.getDetails() != Details.NONE) {
106-
printSummary(summary, testPlanCapturer.testPlan, out);
107+
//get testPlan from summaryListener
108+
testPlanListeners = summaryListener.getTestPlan();
109+
printSummary(summary, out);
107110
}
108111

109112
return summary;
@@ -177,7 +180,7 @@ private Optional<TestExecutionListener> createXmlWritingListener(PrintWriter out
177180
return reportsDir.map(it -> new LegacyXmlReportGeneratingListener(it, out));
178181
}
179182

180-
private void printSummary(TestExecutionSummary summary, TestPlan testPlan, PrintWriter out) {
183+
private void printSummary(TestExecutionSummary summary, PrintWriter out) {
181184
// Otherwise the failures have already been printed in detail
182185
if (EnumSet.of(Details.NONE, Details.SUMMARY, Details.TREE).contains(outputOptions.getDetails())) {
183186
summary.printFailuresTo(out);
@@ -195,7 +198,7 @@ private void printSummary(TestExecutionSummary summary, TestPlan testPlan, Print
195198
ValueWrapper actual = assertionFailedError.getActual();
196199
//apply diff function
197200
if (isCharSequence(expected) && isCharSequence(actual)) {
198-
new DiffPrinter(testPlan).printDiff(out, expected.getStringRepresentation(),
201+
new DiffPrinter(testPlanListeners).printDiff(out, expected.getStringRepresentation(),
199202
actual.getStringRepresentation(), failure.getTestIdentifier());
200203
}
201204
}
@@ -212,14 +215,4 @@ private boolean isCharSequence(ValueWrapper value) {
212215
public interface Factory {
213216
ConsoleTestExecutor create(TestDiscoveryOptions discoveryOptions, TestConsoleOutputOptions outputOptions);
214217
}
215-
216-
private static class TestPlanCapturer implements TestExecutionListener {
217-
218-
private TestPlan testPlan;
219-
220-
@Override
221-
public void testPlanExecutionStarted(TestPlan testPlan) {
222-
this.testPlan = testPlan;
223-
}
224-
}
225218
}

junit-platform-launcher/src/main/java/org/junit/platform/launcher/listeners/SummaryGeneratingListener.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ public TestExecutionSummary getSummary() {
4646
return this.summary;
4747
}
4848

49+
/**
50+
* Get the testPlan of this listener.
51+
*/
52+
public TestPlan getTestPlan() {
53+
return testPlan;
54+
}
55+
4956
@Override
5057
public void testPlanExecutionStarted(TestPlan testPlan) {
5158
this.testPlan = testPlan;

0 commit comments

Comments
 (0)