Skip to content

Commit 5dbc587

Browse files
chore: add a Time log to the output. (#359)
The default Bazel test runner logs a line with 'Time: <duration ms>' when a test target completes. Do the same here to match the behavior.
1 parent 8d73e63 commit 5dbc587

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/CommandLineSummary.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import static org.junit.platform.engine.TestExecutionResult.Status.SUCCESSFUL;
44

55
import java.io.PrintWriter;
6+
import java.time.Duration;
7+
import java.time.Instant;
68
import java.util.Collections;
79
import java.util.LinkedHashMap;
810
import java.util.Map;
@@ -19,10 +21,18 @@ public class CommandLineSummary implements TestExecutionListener {
1921
private final Map<TestIdentifier, Failure> failures =
2022
Collections.synchronizedMap(new LinkedHashMap<>());
2123
private TestPlan testPlan;
24+
private Instant testPlanStart;
25+
private Instant testPlanEnd;
2226

2327
@Override
2428
public void testPlanExecutionStarted(TestPlan testPlan) {
2529
this.testPlan = Objects.requireNonNull(testPlan);
30+
this.testPlanStart = Instant.now();
31+
}
32+
33+
@Override
34+
public void testPlanExecutionFinished(TestPlan testPlan) {
35+
this.testPlanEnd = Instant.now();
2636
}
2737

2838
@Override
@@ -51,6 +61,8 @@ public void writeTo(PrintWriter writer) {
5161

5262
count++;
5363
}
64+
65+
writer.printf("Time: %.3f%n", Duration.between(testPlanStart, testPlanEnd).toMillis() / 1000.0);
5466
}
5567

5668
private static void writeFilteredStackTrace(

0 commit comments

Comments
 (0)