diff --git a/src/main/java/ru/ewc/checklogic/FullServerContext.java b/src/main/java/ru/ewc/checklogic/FullServerContext.java index bb31c90..10c50ba 100644 --- a/src/main/java/ru/ewc/checklogic/FullServerContext.java +++ b/src/main/java/ru/ewc/checklogic/FullServerContext.java @@ -100,8 +100,11 @@ public void perform(final String command, final Map args) { try { this.context.perform(command); this.context = new ComputationContext(this.state, this.tables, this.commands); - } catch (NullPointerException exception) { - throw new DecitaException("Command file for '%s' not found".formatted(command)); + } catch (Throwable exception) { + throw new IllegalStateException( + "Command file for '%s' not found".formatted(command), + exception + ); } } diff --git a/src/main/java/ru/ewc/checklogic/TestResult.java b/src/main/java/ru/ewc/checklogic/TestResult.java index b70cb15..9176d09 100644 --- a/src/main/java/ru/ewc/checklogic/TestResult.java +++ b/src/main/java/ru/ewc/checklogic/TestResult.java @@ -37,10 +37,11 @@ public String result() { public String asHtmlTableRow() { return String.format( - "%s%s%s", + "%s%s%s", + this.successful ? "table-success" : "table-danger", this.file, this.result(), - this.error + this.error.replace("\n", "
").replace(" ", "    ") ); } } diff --git a/src/main/java/ru/ewc/checklogic/server/WebPages.java b/src/main/java/ru/ewc/checklogic/server/WebPages.java index e52e791..1340385 100644 --- a/src/main/java/ru/ewc/checklogic/server/WebPages.java +++ b/src/main/java/ru/ewc/checklogic/server/WebPages.java @@ -26,6 +26,8 @@ import com.renomad.minum.web.Response; import java.io.File; import java.nio.file.Files; +import java.util.Comparator; +import java.util.List; import java.util.Map; import java.util.stream.Collectors; import lombok.SneakyThrows; @@ -70,12 +72,28 @@ public Response noTestsFolder() { } public Response testPage() { - final String results = FileUtils.readFileNames(this.root) + final long start = System.currentTimeMillis(); + final List testResults = FileUtils.readFileNames(this.root) .map(this::performTest) + .toList(); + final String results = testResults.stream() + .sorted(Comparator.comparing(TestResult::result)) .map(TestResult::asHtmlTableRow) .collect(Collectors.joining()); + final double executionTime = (System.currentTimeMillis() - start) / 1000.0; return Response.htmlOk( - this.templateNamed("templates/test.html", Map.of("tests", "%s".formatted(results))) + this.templateNamed( + "templates/test.html", + Map.of( + "tests", "%s".formatted(results), + "stats", "%d test(s) performed in %.3f second(s), %d passed, %d failed".formatted( + testResults.size(), + executionTime, + testResults.stream().filter(TestResult::successful).count(), + testResults.stream().filter(result -> !result.successful()).count() + ) + ) + ) ); } @@ -124,7 +142,6 @@ private TestResult performTest(final TestData test) { } catch (IllegalStateException exception) { result = new TestResult(test.toString(), false, exception.getMessage()); } - return result; } diff --git a/src/main/resources/templates/test.html b/src/main/resources/templates/test.html index 7a8dc15..045bc8f 100644 --- a/src/main/resources/templates/test.html +++ b/src/main/resources/templates/test.html @@ -39,13 +39,18 @@

Test results

- - - - - - - {{ tests }} +
TestResultMessage
+ + + + + + + + + + {{ tests }} +
{{ stats }}
TestResultMessage
\ No newline at end of file