Bug 566379 - Flush testEnded messages to client

The testEnded and testFailed messages weren't being flushed back to the
client, so it was up to a subsequent message send to flush the queue.
This resulted in incorrect numbers being reported for test cases, since
the time displayed in the UI is measured from when the testEnded message
was received from the test runner.

By flushing the messages as they are created, we ensure that the client
can calculate reliable times for test runs, such as when a JUnit 4
BeforeClass or a JUnit 5 BeforeAll annotation is used.

Change-Id: Ife4ee1671f3c28df45f6d3f1f82d036951a57dd4
Signed-off-by: Alex Blewitt <alex.blewitt@gmail.com>
diff --git a/org.eclipse.jdt.junit.runtime/src/org/eclipse/jdt/internal/junit/runner/FirstRunExecutionListener.java b/org.eclipse.jdt.junit.runtime/src/org/eclipse/jdt/internal/junit/runner/FirstRunExecutionListener.java
index 3520d0d..38892c2 100644
--- a/org.eclipse.jdt.junit.runtime/src/org/eclipse/jdt/internal/junit/runner/FirstRunExecutionListener.java
+++ b/org.eclipse.jdt.junit.runtime/src/org/eclipse/jdt/internal/junit/runner/FirstRunExecutionListener.java
@@ -30,11 +30,13 @@
 
 	public void notifyTestEnded(ITestIdentifier test) {
 		sendMessage(test, MessageIds.TEST_END);
+		fSender.flush();
 	}
 
 	public void notifyTestFailed(TestReferenceFailure failure) {
 		sendMessage(failure.getTest(), failure.getStatus());
 		sendFailure(failure, MessageIds.TRACE_START, MessageIds.TRACE_END);
+		// fSender.flush(); // flush is implicitly done by sendFailure()
 	}
 
 	public void notifyTestStarted(ITestIdentifier test) {