@@ -34,17 +34,21 @@ public class Junit5TestListener implements TestExecutionListener {
3434 private final Class <?> testClass ;
3535
3636 // To help give a reasonable (though imprecise) guess at the runtime for unpaired failures
37- private long startTime = System .currentTimeMillis ();
37+ private long testStartTime ;
38+ private long testPlanStartTime ;
3839
3940 public Junit5TestListener (List <TestResult > results , Level stdErrLogLevel , Level stdOutLogLevel , Class <?> testClass ) {
4041 this .results = results ;
4142 this .stdErrLogLevel = stdErrLogLevel ;
4243 this .stdOutLogLevel = stdOutLogLevel ;
4344 this .testClass = testClass ;
45+ this .testStartTime = System .currentTimeMillis ();
46+ this .testPlanStartTime = System .currentTimeMillis ();
4447 }
4548
4649 @ Override
4750 public void testPlanExecutionStarted (TestPlan testPlan ) {
51+ this .testPlanStartTime = System .currentTimeMillis ();
4852 listener .testPlanExecutionStarted (testPlan );
4953 }
5054
@@ -54,7 +58,7 @@ public void testPlanExecutionFinished(TestPlan testPlan) {
5458 // testStarted was called for latest test, but not the testFinished
5559 // report all failures as unbounded
5660 for (TestExecutionSummary .Failure failure : listener .getSummary ().getFailures ()) {
57- long runtime = System .currentTimeMillis () - startTime ;
61+ long runtime = System .currentTimeMillis () - this . testPlanStartTime ;
5862 String className = testClass .getCanonicalName ();
5963 String methodName = testIdentifier .getDisplayName ().replace ("()" , "" );
6064 results .add (
@@ -81,8 +85,6 @@ public void executionStarted(TestIdentifier testIdentifier) {
8185 if (!testIdentifier .isTest ()) {
8286 return ;
8387 }
84- this .startTime = System .currentTimeMillis ();
85-
8688 // Create an intermediate stdout/stderr to capture any debugging statements (usually in the
8789 // form of System.out.println) the developer is using to debug the test.
8890 originalOut = System .out ;
@@ -112,6 +114,7 @@ public void executionStarted(TestIdentifier testIdentifier) {
112114 julLogHandler = addStreamHandler (rootLogger , julLogBytes , formatter , stdOutLogLevel );
113115 julErrLogHandler = addStreamHandler (rootLogger , julErrLogBytes , formatter , stdErrLogLevel );
114116
117+ this .testStartTime = System .currentTimeMillis ();
115118 listener .executionStarted (testIdentifier );
116119 }
117120
@@ -180,7 +183,7 @@ public void executionFinished(TestIdentifier testIdentifier, TestExecutionResult
180183
181184 String className = testClass .getCanonicalName ();
182185 String methodName = testIdentifier .getDisplayName ().replace ("()" , "" );
183- long runTime = System .currentTimeMillis () - this .startTime ;
186+ long runTime = System .currentTimeMillis () - this .testStartTime ;
184187 results .add (
185188 new TestResult (
186189 className ,
0 commit comments