Skip to content

Commit d5a16e3

Browse files
committed
ConsoleServiceTest: wait for EDTPrinters to finish
Calling .get() on the Future returned by ThreadService.run ensures that the events will be seen in subsequent checks. Added comments clarifying where the runs are expected to have completed. Closes #149
1 parent c2b4274 commit d5a16e3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/test/java/org/scijava/console/ConsoleServiceTest.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,15 @@ public void testMultipleContextOutput() throws InterruptedException,
167167
ts1.run(new Printer(c1RunOut, c1RunErr)).get();
168168
ts2.run(new Printer(c2RunOut, c2RunErr)).get();
169169

170-
ts1.run(new EDTPrinter(ts1, c1InvokeOut, c1InvokeErr));
171-
ts2.run(new EDTPrinter(ts2, c2InvokeOut, c2InvokeErr));
170+
ts1.run(new EDTPrinter(ts1, c1InvokeOut, c1InvokeErr)).get();
171+
ts2.run(new EDTPrinter(ts2, c2InvokeOut, c2InvokeErr)).get();
172172

173173
c2.dispose();
174174

175+
// NB: all printing is assumed to have completed. If there are test failures
176+
// at this point it is likely due to a thread not having completed before
177+
// the assert checks.
178+
175179
assertEquals(6, events1.size());
176180
assertOutputEvent(Source.STDOUT, globalOut, false, events1.get(0));
177181
assertOutputEvent(Source.STDERR, globalErr, false, events1.get(1));

0 commit comments

Comments
 (0)