From 88f1375d36a9713447445dfe6107b3f25bbc2bc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Sch=C3=A4fer?= Date: Thu, 25 Sep 2014 13:57:49 +0200 Subject: [PATCH] made the statistics page nicer --- .../report/html/StatisticsPageHtmlWriter.java | 29 ++++++++++---- .../tngtech/jgiven/report/html/default.css | 38 ++++++++++++++++++- 2 files changed, 57 insertions(+), 10 deletions(-) diff --git a/jgiven-core/src/main/java/com/tngtech/jgiven/report/html/StatisticsPageHtmlWriter.java b/jgiven-core/src/main/java/com/tngtech/jgiven/report/html/StatisticsPageHtmlWriter.java index ae259bdfb9..f07bea9d08 100644 --- a/jgiven-core/src/main/java/com/tngtech/jgiven/report/html/StatisticsPageHtmlWriter.java +++ b/jgiven-core/src/main/java/com/tngtech/jgiven/report/html/StatisticsPageHtmlWriter.java @@ -49,14 +49,27 @@ private void writeIndexFile( File toDir ) { } private void writeStatistics() { - printWriter.write( "Number of Classes: " + statistics.numClasses + "
" ); - printWriter.write( "Number of Scenarios: " + statistics.numScenarios + "
" ); - printWriter.write( "Number of Cases: " + statistics.numCases + "
" ); - printWriter.write( "Number of Failed Cases: " + statistics.numFailedCases + "
" ); - printWriter.write( "Number of Steps: " + statistics.numSteps + "
" ); - printWriter.write( "Total Time: " + DurationFormatter.format( statistics.durationInNanos ) + "
" ); - + printWriter.write( "
" ); + writeStatisticNumber( statistics.numClasses, "classes" ); + writeStatisticNumber( statistics.numScenarios, "scenarios" ); + writeStatisticNumber( statistics.numCases, "cases" ); + writeStatisticNumber( statistics.numSteps, "steps" ); + writeStatisticNumber( "" + statistics.numFailedCases, "failed cases", statistics.numFailedCases > 0 ? "failed" : "" ); + writeStatisticNumber( DurationFormatter.format( statistics.durationInNanos ), "total time" ); long averageNanos = statistics.numCases != 0 ? statistics.durationInNanos / statistics.numCases : 0; - printWriter.write( "Average duration per Case: " + DurationFormatter.format( averageNanos ) ); + writeStatisticNumber( DurationFormatter.format( averageNanos ), "time / case" ); + printWriter.println( "
" ); + } + + private void writeStatisticNumber( int number, String name ) { + writeStatisticNumber( number + "", name, "" ); + } + + private void writeStatisticNumber( String number, String name ) { + writeStatisticNumber( number, name, "" ); + } + + private void writeStatisticNumber( String number, String name, String extraClass ) { + printWriter.write( "
" + number + "
" + name + "
" ); } } diff --git a/jgiven-core/src/main/resources/com/tngtech/jgiven/report/html/default.css b/jgiven-core/src/main/resources/com/tngtech/jgiven/report/html/default.css index ec4d9c7705..bc146470a3 100644 --- a/jgiven-core/src/main/resources/com/tngtech/jgiven/report/html/default.css +++ b/jgiven-core/src/main/resources/com/tngtech/jgiven/report/html/default.css @@ -181,8 +181,6 @@ h1 { text-shadow: 1px 1px 1px #fff; } - - #toc > .icon-cancel { position: absolute; top: 2px; @@ -651,6 +649,42 @@ ul.steps li { padding-top:10px; } +.statistics-number { + padding: 20px; + border: solid #e0e0e0 1px; + border-radius: 20px; + display: inline-block; + margin-right: 20px; + text-align: center; + background-color: #f0f0f0; +} + +.statistics-number.failed { + background-color: #f0f0f0; +} + +.statistics-number > i { + font-size: 20px; + color: #222; + font-weight: 200; + font-style: normal; +} + +.statistics-number.failed > i { + color: red; + font-weight: bold; +} + +.statistics-number > b { + text-transform: uppercase; + font-size: 14px; + color: gray; +} + +.statistics-number.failed > b { + color: red; +} + .duration { opacity: 0.5; font-size: 10px;