Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(logger): Summary duration format #138

Merged
merged 1 commit into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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