Skip to content

Commit

Permalink
fix(logger): Summary duration format
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseLion committed Sep 4, 2023
1 parent fbb9b98 commit 891d2ee
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.gradle.api.tasks.testing.TestResult;
import org.gradle.api.tasks.testing.TestResult.ResultType;

import groovy.time.TimeDuration;
import io.github.joselion.prettyjupiter.lib.helpers.Color;
import io.github.joselion.prettyjupiter.lib.helpers.Common;
import io.github.joselion.prettyjupiter.lib.helpers.Icon;
Expand Down Expand Up @@ -99,13 +100,20 @@ public void logSummary(final TestDescriptor descriptor, final TestResult result)
final var failed = Text.colored(Color.RED, Long.toString(result.getFailedTestCount()).concat(" failed"));
final var skipped = Text.colored(Color.YELLOW, Long.toString(result.getSkippedTestCount()).concat(" skipped"));
final var time = Duration.ofMillis(result.getEndTime()).minusMillis(result.getStartTime());
final var stats = "%s %d tests completed, %s, %s, %s (%.3f seconds)".formatted(
final var timeDuration = new TimeDuration(
Math.toIntExact(time.toDaysPart()),
time.toHoursPart(),
time.toMinutesPart(),
time.toSecondsPart(),
time.toMillisPart()
);
final var stats = "%s %d tests completed, %s, %s, %s (%s)".formatted(
status.icon(),
result.getTestCount(),
succeed,
failed,
skipped,
time.toMillis() / 1000.0
timeDuration
);
final var report = "Report: ".concat(this.testTask.getReports().getHtml().getEntryPoint().toString());
final var summary = Stream.of(stats, "", report).collect(joining("\n"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@
final var results = mock(TestResult.class);
when(results.getResultType()).thenReturn(entry.getKey());
when(results.getStartTime()).thenReturn(1583909261673L);
when(results.getEndTime()).thenReturn(1583909305290L);
when(results.getEndTime()).thenReturn(1583909325290L);
when(results.getTestCount()).thenReturn(136L);
when(results.getSuccessfulTestCount()).thenReturn(120L);
when(results.getFailedTestCount()).thenReturn(10L);
Expand All @@ -252,7 +252,7 @@

final var plainSummary = """
%s 136 tests completed, \u001B[32m120 succeed\u001B[0m, \u001B[31m10 failed\u001B[0m, \
\u001B[33m6 skipped\u001B[0m (43.617 seconds)\
\u001B[33m6 skipped\u001B[0m (1 minutes, 3.617 seconds)\
"""
.formatted(entry.getValue());
final var visibleText = Text.uncolored(plainSummary);
Expand Down

0 comments on commit 891d2ee

Please sign in to comment.