-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jan Schäfer
committed
Sep 25, 2014
1 parent
22f98c0
commit 0f278cf
Showing
6 changed files
with
100 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
jgiven-core/src/main/java/com/tngtech/jgiven/report/html/StatisticsPageHtmlWriter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package com.tngtech.jgiven.report.html; | ||
|
||
import java.io.File; | ||
import java.io.PrintWriter; | ||
|
||
import com.tngtech.jgiven.impl.util.DurationFormatter; | ||
import com.tngtech.jgiven.impl.util.ResourceUtil; | ||
import com.tngtech.jgiven.report.impl.CommonReportHelper; | ||
import com.tngtech.jgiven.report.model.ReportModel; | ||
import com.tngtech.jgiven.report.model.ReportStatistics; | ||
|
||
public class StatisticsPageHtmlWriter { | ||
|
||
private final HtmlTocWriter tocWriter; | ||
private final ReportStatistics statistics; | ||
private PrintWriter printWriter; | ||
private HtmlWriterUtils utils; | ||
|
||
public StatisticsPageHtmlWriter( HtmlTocWriter tocWriter, ReportStatistics statistics ) { | ||
this.tocWriter = tocWriter; | ||
this.statistics = statistics; | ||
} | ||
|
||
public void write( File toDir ) { | ||
writeIndexFile( toDir ); | ||
} | ||
|
||
private void writeIndexFile( File toDir ) { | ||
File file = new File( toDir, "index.html" ); | ||
printWriter = CommonReportHelper.getPrintWriter( file ); | ||
utils = new HtmlWriterUtils( printWriter ); | ||
try { | ||
ReportModelHtmlWriter htmlWriter = new ReportModelHtmlWriter( printWriter ); | ||
htmlWriter.writeHtmlHeader( "Scenarios" ); | ||
|
||
ReportModel reportModel = new ReportModel(); | ||
reportModel.setClassName( ".Scenarios" ); | ||
|
||
tocWriter.writeToc( printWriter ); | ||
htmlWriter.visit( reportModel ); | ||
|
||
writeStatistics(); | ||
|
||
htmlWriter.visitEnd( reportModel ); | ||
htmlWriter.writeHtmlFooter(); | ||
} finally { | ||
ResourceUtil.close( printWriter ); | ||
} | ||
} | ||
|
||
private void writeStatistics() { | ||
printWriter.write( "Number of Classes: " + statistics.numClasses + "<br>" ); | ||
printWriter.write( "Number of Scenarios: " + statistics.numScenarios + "<br>" ); | ||
printWriter.write( "Number of Cases: " + statistics.numCases + "<br>" ); | ||
printWriter.write( "Number of Failed Cases: " + statistics.numFailedCases + "<br>" ); | ||
printWriter.write( "Number of Steps: " + statistics.numSteps + "<br>" ); | ||
printWriter.write( "Total Time: " + DurationFormatter.format( statistics.durationInNanos ) + "<br>" ); | ||
printWriter.write( "Average duration per Case: " | ||
+ DurationFormatter.format( statistics.durationInNanos / statistics.numCases ) ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters