Skip to content

Commit

Permalink
feat(extension): Update default threshold (#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseLion authored Nov 3, 2023
1 parent 9625854 commit d912c5f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public Duration(final ObjectFactory objects) {
this.customThreshold = objects.mapProperty(String.class, Integer.class);

this.enabled.convention(true);
this.threshold.convention(75);
this.threshold.convention(200);
this.customThreshold.convention(Map.of());
}

Expand Down Expand Up @@ -96,7 +96,7 @@ public Failure(final ObjectFactory objects) {
this.maxTraceLines = objects.property(Integer.class);

this.maxMessageLines.convention(15);
this.maxTraceLines.convention(10);
this.maxTraceLines.convention(15);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
final var failure = extension.getFailure();

assertThat(duration.getEnabled().get()).isTrue();
assertThat(duration.getThreshold().get()).isEqualTo(75);
assertThat(duration.getThreshold().get()).isEqualTo(200);
assertThat(duration.getCustomThreshold().get()).isEmpty();
assertThat(failure.getMaxMessageLines().get()).isEqualTo(15);
assertThat(failure.getMaxTraceLines().get()).isEqualTo(10);
assertThat(failure.getMaxTraceLines().get()).isEqualTo(15);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.github.joselion.prettyjupiter.lib;

import static java.util.Arrays.stream;
import static org.assertj.core.api.Assertions.entry;
import static org.junit.jupiter.api.DynamicTest.dynamicTest;
import static org.mockito.ArgumentMatchers.anyString;
Expand Down Expand Up @@ -151,11 +152,11 @@
@Nested class when_the_result_has_different_durations {
@TestFactory Stream<DynamicTest> logs_the_result_with_the_matching_duration_color() {
return Stream.of(
entry(Color.RED, 100L),
entry(Color.RED, 75L),
entry(Color.YELLOW, 50L),
entry(Color.YELLOW, 38L),
entry(Color.WHITE, 25L),
entry(Color.RED, 250L),
entry(Color.RED, 200L),
entry(Color.YELLOW, 150L),
entry(Color.YELLOW, 100L),
entry(Color.WHITE, 50L),
entry(Color.WHITE, 0L)
)
.map(entry ->
Expand Down Expand Up @@ -258,8 +259,8 @@
final var visibleText = Text.uncolored(plainSummary);
final var plainReport = "Report: path/to/report/file.html";
final var reportTrailSpace = " ".repeat(visibleText.length() - plainReport.length());
final var hidden1 = exception.getStackTrace().length - 10;
final var hidden2 = causeD.getStackTrace().length - 10;
final var hidden1 = exception.getStackTrace().length - 15;
final var hidden2 = causeD.getStackTrace().length - 15;
final var failedTest = Icon.FAILURE + " \u001B[31mTest description 1\u001B[0m (\u001B[97m0ms\u001B[0m)";
final var ordered = inOrder(logger);

Expand All @@ -279,33 +280,19 @@
ordered.verify(logger).lifecycle("");
ordered.verify(logger).lifecycle(" Stack trace:");
ordered.verify(logger).lifecycle(" \u001B[90mjava.lang.Exception: Multi line exception!");
ordered.verify(logger).lifecycle(" at " + exception.getStackTrace()[0]);
ordered.verify(logger).lifecycle(" at " + exception.getStackTrace()[1]);
ordered.verify(logger).lifecycle(" at " + exception.getStackTrace()[2]);
ordered.verify(logger).lifecycle(" at " + exception.getStackTrace()[3]);
ordered.verify(logger).lifecycle(" at " + exception.getStackTrace()[4]);
ordered.verify(logger).lifecycle(" at " + exception.getStackTrace()[5]);
ordered.verify(logger).lifecycle(" at " + exception.getStackTrace()[6]);
ordered.verify(logger).lifecycle(" at " + exception.getStackTrace()[7]);
ordered.verify(logger).lifecycle(" at " + exception.getStackTrace()[8]);
ordered.verify(logger).lifecycle(" at " + exception.getStackTrace()[9]);
stream(exception.getStackTrace()).limit(15).forEachOrdered(trace ->
ordered.verify(logger).lifecycle(" at " + trace)
);
ordered.verify(logger).lifecycle(" --- and " + hidden1 + " more ---\u001B[0m");
ordered.verify(logger).lifecycle("\n");
ordered.verify(logger).lifecycle("\u001B[91m(2)\u001B[0m Test description 1:");
ordered.verify(logger).lifecycle(" \u001B[91mjava.lang.Exception: Cause of error C\u001B[0m");
ordered.verify(logger).lifecycle("");
ordered.verify(logger).lifecycle(" Stack trace:");
ordered.verify(logger).lifecycle(" \u001B[90mjava.lang.Exception: Cause of error C");
ordered.verify(logger).lifecycle(" at " + causeD.getStackTrace()[0]);
ordered.verify(logger).lifecycle(" at " + causeD.getStackTrace()[1]);
ordered.verify(logger).lifecycle(" at " + causeD.getStackTrace()[2]);
ordered.verify(logger).lifecycle(" at " + causeD.getStackTrace()[3]);
ordered.verify(logger).lifecycle(" at " + causeD.getStackTrace()[4]);
ordered.verify(logger).lifecycle(" at " + causeD.getStackTrace()[5]);
ordered.verify(logger).lifecycle(" at " + causeD.getStackTrace()[6]);
ordered.verify(logger).lifecycle(" at " + causeD.getStackTrace()[7]);
ordered.verify(logger).lifecycle(" at " + causeD.getStackTrace()[8]);
ordered.verify(logger).lifecycle(" at " + causeD.getStackTrace()[9]);
stream(causeD.getStackTrace()).limit(15).forEachOrdered(trace ->
ordered.verify(logger).lifecycle(" at " + trace)
);
ordered.verify(logger).lifecycle(" --- and " + hidden2 + " more ---\u001B[0m");
ordered.verify(logger).lifecycle("\n");
ordered.verify(logger).lifecycle("╔═" + "═".repeat(visibleText.length()) + "══╗");
Expand Down

0 comments on commit d912c5f

Please sign in to comment.