diff --git a/CHANGELOG.md b/CHANGELOG.md index 9227d740c2..68cb77b1ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,11 @@ public @interface FeatureHtml5Report { } * Classes are shown now in hierarchical navigation tree and scenarios can be listed by package [#91](https://github.com/TNG/JGiven/pull/91) +## Removed Features + +### Removed the old static HTML report generator +* As the HTML5 report supports all the features of the static HTML report, the static HTML report has been completely removed to avoid duplicate efforts when implementing new features. + ## Fixed Issues * HTML5 Report: tables with duplicate entries cannot be used as step parameters [#89](https://github.com/TNG/JGiven/issues/89) diff --git a/build.gradle b/build.gradle index 33f595bf6e..a66a31fe70 100644 --- a/build.gradle +++ b/build.gradle @@ -144,16 +144,6 @@ subprojects { ignoreFailures = true } - task jgivenReport(type: JavaExec) { - main = 'com.tngtech.jgiven.report.ReportGenerator' - args '--sourceDir=build/reports/jgiven/json', - '--targetDir=build/reports/jgiven/html', - '--format=html', - '--customcss=build/resources/test/jgiven/custom.css' - - classpath = configurations.testCompile - } - task jgivenHtml5Report(type: JavaExec) { main = 'com.tngtech.jgiven.report.ReportGenerator' args '--sourceDir=build/reports/jgiven/json', diff --git a/jgiven-core/src/main/java/com/tngtech/jgiven/report/ReportGenerator.java b/jgiven-core/src/main/java/com/tngtech/jgiven/report/ReportGenerator.java index 3451a83dea..8e7f1de1eb 100644 --- a/jgiven-core/src/main/java/com/tngtech/jgiven/report/ReportGenerator.java +++ b/jgiven-core/src/main/java/com/tngtech/jgiven/report/ReportGenerator.java @@ -12,7 +12,6 @@ import com.tngtech.jgiven.exception.JGivenInstallationException; import com.tngtech.jgiven.exception.JGivenInternalDefectException; import com.tngtech.jgiven.report.asciidoc.AsciiDocReportGenerator; -import com.tngtech.jgiven.report.html.StaticHtmlReportGenerator; import com.tngtech.jgiven.report.json.ReportModelReader; import com.tngtech.jgiven.report.model.CompleteReportModel; import com.tngtech.jgiven.report.text.PlainTextReportGenerator; @@ -96,9 +95,7 @@ public void generate() throws Exception { CompleteReportModel reportModel = new ReportModelReader().readDirectory( getSourceDirectory() ); - if( format == HTML ) { - generateStaticHtmlReport( reportModel ); - } else if( format == HTML5 ) { + if( format == HTML5 || format == HTML ) { generateHtml5Report( reportModel ); } else if( format == TEXT ) { new PlainTextReportGenerator().generate( reportModel, getTargetDirectory() ); @@ -108,11 +105,6 @@ public void generate() throws Exception { } - private void generateStaticHtmlReport( CompleteReportModel reportModel ) throws IOException { - new StaticHtmlReportGenerator().generate( reportModel, getTargetDirectory() ); - copyCustomCssFile( getTargetDirectory() ); - } - private void copyCustomCssFile( File targetDirectory ) throws IOException { if( getCustomCssFile() != null ) { if( !getCustomCssFile().canRead() ) { @@ -141,7 +133,7 @@ private void generateHtml5Report( CompleteReportModel reportModel ) throws IOExc private static void printUsageAndExit() { System.err.println( "Options: [--format=] [--sourceDir=] [--targetDir=] [--customcss=]" ); // NOSONAR - System.err.println( " = html, html5, or text, default is html" ); + System.err.println( " = html or text, default is html" ); System.exit( 1 ); } diff --git a/jgiven-core/src/main/java/com/tngtech/jgiven/report/html/DataTableScenarioHtmlWriter.java b/jgiven-core/src/main/java/com/tngtech/jgiven/report/html/DataTableScenarioHtmlWriter.java deleted file mode 100644 index bcd43d113b..0000000000 --- a/jgiven-core/src/main/java/com/tngtech/jgiven/report/html/DataTableScenarioHtmlWriter.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.tngtech.jgiven.report.html; - -import java.io.PrintWriter; - -import com.tngtech.jgiven.report.model.*; - -public class DataTableScenarioHtmlWriter extends ScenarioHtmlWriter { - - public DataTableScenarioHtmlWriter( PrintWriter writer, ReportModel reportModel ) { - super( writer, reportModel ); - } - - @Override - public void visit( ScenarioCaseModel scenarioCase ) { - if( scenarioCase.getCaseNr() == 1 ) { - super.visit( scenarioCase ); - } else { - this.scenarioCase = scenarioCase; - } - } - - @Override - void printCaseHeader( ScenarioCaseModel scenarioCase ) {} - - @Override - public void visitEnd( ScenarioCaseModel scenarioCase ) { - if( scenarioCase.getCaseNr() == 1 ) { - writer.println( "" ); - writer.println( "

Cases:

" ); - writer.println( "" ); - writer.println( "" ); - writer.print( "" ); - for( String param : scenarioModel.getDerivedParameters() ) { - writer.print( "" ); - } - writer.print( "" ); - writer.println( "" ); - } - - writer.println( "" ); - writer.print( "" ); - for( String arg : scenarioCase.getDerivedArguments() ) { - writer.print( "" ); - } - writer.print( "" ); - - writer.println( "" ); - } - - @Override - public void visitEnd( ScenarioModel scenarioModel ) { - writer.println( "
#" + param + "Status
" + scenarioCase.getCaseNr() + "" + arg + "" ); - - if( !scenarioCase.success ) { - writer.println( "
Failed: " + scenarioCase.errorMessage + "
" ); - } else { - writeStatusIcon( scenarioCase.getExecutionStatus() ); - } - - utils.writeDuration( scenarioCase.durationInNanos ); - - writer.print( "
" ); - super.visitEnd( scenarioModel ); - } - - @Override - public void visit( StepModel stepModel ) { - if( scenarioCase.getCaseNr() == 1 ) { - super.visit( stepModel ); - } - } - - @Override - String formatValue( Word value ) { - String paramName = findParameterName( value ); - return "<" + paramName + ">"; - } - - private String findParameterName( Word word ) { - return word.getArgumentInfo().getParameterName(); - } - -} diff --git a/jgiven-core/src/main/java/com/tngtech/jgiven/report/html/HtmlTocWriter.java b/jgiven-core/src/main/java/com/tngtech/jgiven/report/html/HtmlTocWriter.java deleted file mode 100644 index 4179a14aa2..0000000000 --- a/jgiven-core/src/main/java/com/tngtech/jgiven/report/html/HtmlTocWriter.java +++ /dev/null @@ -1,165 +0,0 @@ -package com.tngtech.jgiven.report.html; - -import static java.lang.String.format; - -import java.io.PrintWriter; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -import com.google.common.base.Function; -import com.google.common.collect.ImmutableListMultimap; -import com.google.common.collect.Lists; -import com.google.common.collect.Multimaps; -import com.google.common.collect.Ordering; -import com.google.common.io.Files; -import com.tngtech.jgiven.report.html.PackageTocBuilder.PackageToc; -import com.tngtech.jgiven.report.model.*; - -public class HtmlTocWriter { - protected PrintWriter writer; - private final CompleteReportModel reportModel; - private final PackageToc packageToc; - private final ImmutableListMultimap groupedTags; - - public HtmlTocWriter( CompleteReportModel reportModel, PackageToc packageToc ) { - this.reportModel = reportModel; - this.packageToc = packageToc; - groupedTags = getGroupedTags(); - } - - public void writeToc( PrintWriter writer ) { - this.writer = writer; - writer.println( "
" ); - writer.println( "
" ); - writer.println( "
" ); - writer.println( "" ); - writeSearchInput(); - writeSummary(); - writePackages(); - writeTagLinks(); - writer.println( "
" ); - writer.println( "
" ); - } - - private void writeSummary() { - writer.println( "

Summary

" ); - writer.println( "
    " ); - ReportStatistics totalStatistics = reportModel.getTotalStatistics(); - writeLink( totalStatistics.numScenarios, "all.html", "All Scenarios" ); - writeLink( totalStatistics.numPendingScenarios, "pending.html", "Pending Scenarios" ); - writeLink( totalStatistics.numFailedScenarios, "failed.html", "Failed Scenarios" ); - writer.println( "
" ); - } - - private void writeLink( int count, String fileName, String title ) { - if( count > 0 ) { - writer.print( "
  • " + title ); - writer.println( " " + count + "" ); - } - } - - private void writeSearchInput() { - writer.println( "" ); - } - - private void writePackages() { - writer.println( "

    Test Classes

    " ); - writer.println( "
      " ); - printPackageToc( "", packageToc ); - writer.println( "
    " ); - } - - private void printPackageTocs( Iterable tocs ) { - for( PackageToc toc : tocs ) { - printPackageToc( "", toc ); - } - } - - private void printPackageToc( String prefix, PackageToc toc ) { - String name = prefix + toc.getLastName(); - if( toc.files.isEmpty() && toc.packages.size() == 1 ) { - String newPrefix = name.equals( "" ) ? "" : name + "."; - printPackageToc( newPrefix, toc.packages.get( 0 ) ); - } else { - if( !toc.name.equals( "" ) ) { - writer.print( "
  • " + name + "

    " ); - String collapsed = "collapsed"; - writer.println( "
  • " ); - } - } - } - - private void printClassLinks( List files ) { - for( ReportModelFile modelFile : files ) { - writeClassLink( modelFile ); - } - } - - private void writeClassLink( ReportModelFile model ) { - writer.print( format( "
  • %s
  • ", - Files.getNameWithoutExtension( model.file.getName() ) + ".html", - model.model.getSimpleClassName() ) ); - } - - private void writeTagLinks() { - if( groupedTags.isEmpty() ) { - return; - } - - writer.println( "

    Tags

    " ); - writer.println( "
      " ); - List orderedKeys = Ordering.natural().sortedCopy( groupedTags.keySet() ); - for( String key : orderedKeys ) { - writer.println( "
    • " ); - String tagId = "tag" + key; - writer.println( "

      " + key + "

      " ); - writer.println( "" ); - } - writer.println( "
    " ); - } - - private ImmutableListMultimap getGroupedTags() { - ImmutableListMultimap multiMap = Multimaps.index( reportModel.getAllTags(), new Function() { - @Override - public String apply( Tag input ) { - return input.getName(); - } - } ); - return multiMap; - } - - public List getSortedTags() { - List sortedTags = Lists.newArrayList( reportModel.getAllTags() ); - Collections.sort( sortedTags, new Comparator() { - @Override - public int compare( Tag o1, Tag o2 ) { - return o1.toString().compareTo( o2.toString() ); - } - } ); - return sortedTags; - } - - private void writeTagLink( Tag tag, List list ) { - writer.println( format( "
  • %s", - tagToFilename( tag ), - tag.toString() ) ); - } - - static String tagToFilename( Tag tag ) { - return tag.toEscapedString() + ".html"; - } - -} diff --git a/jgiven-core/src/main/java/com/tngtech/jgiven/report/html/HtmlWriterUtils.java b/jgiven-core/src/main/java/com/tngtech/jgiven/report/html/HtmlWriterUtils.java deleted file mode 100644 index 0b7bbbfb76..0000000000 --- a/jgiven-core/src/main/java/com/tngtech/jgiven/report/html/HtmlWriterUtils.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.tngtech.jgiven.report.html; - -import static java.lang.String.format; - -import java.io.PrintWriter; - -import com.tngtech.jgiven.report.util.DurationFormatter; - -public class HtmlWriterUtils { - - private final PrintWriter writer; - - public HtmlWriterUtils( PrintWriter writer ) { - this.writer = writer; - } - - public void writeHtmlHeader( String title ) { - writer.println( "" ); - writer.println( "" ); - writer.println( " " ); - writer.println( format( " %s", title ) ); - writer.println( " " ); - writer.println( "" ); - writer.println( "" ); - } - - public void writeHtmlFooter() { - writer.println( "" ); - writer.println( "" ); - } - - public void writeDuration( long durationInNanos ) { - writer.print( " (" + DurationFormatter.format( durationInNanos ) + ")" ); - } - -} diff --git a/jgiven-core/src/main/java/com/tngtech/jgiven/report/html/MultiCaseScenarioHtmlWriter.java b/jgiven-core/src/main/java/com/tngtech/jgiven/report/html/MultiCaseScenarioHtmlWriter.java deleted file mode 100644 index e691058982..0000000000 --- a/jgiven-core/src/main/java/com/tngtech/jgiven/report/html/MultiCaseScenarioHtmlWriter.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.tngtech.jgiven.report.html; - -import java.io.PrintWriter; - -import com.tngtech.jgiven.report.model.ReportModel; - -public class MultiCaseScenarioHtmlWriter extends ScenarioHtmlWriter { - - public MultiCaseScenarioHtmlWriter( PrintWriter writer, ReportModel reportModel ) { - super( writer, reportModel ); - } - -} diff --git a/jgiven-core/src/main/java/com/tngtech/jgiven/report/html/PackageTocBuilder.java b/jgiven-core/src/main/java/com/tngtech/jgiven/report/html/PackageTocBuilder.java deleted file mode 100644 index 78e6e73ddc..0000000000 --- a/jgiven-core/src/main/java/com/tngtech/jgiven/report/html/PackageTocBuilder.java +++ /dev/null @@ -1,115 +0,0 @@ -package com.tngtech.jgiven.report.html; - -import java.util.*; - -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import com.google.common.collect.Queues; -import com.tngtech.jgiven.report.model.ReportModelFile; - -public class PackageTocBuilder { - - private final List sortedModels; - private final Map tocs = Maps.newLinkedHashMap(); - - public PackageTocBuilder( List models ) { - this.sortedModels = models; - } - - static class PackageToc { - String name; - List packages = Lists.newArrayList(); - List files = Lists.newArrayList(); - - public String getParentName() { - int lastIndexOf = name.lastIndexOf( '.' ); - if( lastIndexOf == -1 ) { - return ""; - } - return name.substring( 0, lastIndexOf ); - } - - public String getLastName() { - int lastIndexOf = name.lastIndexOf( '.' ); - if( lastIndexOf == -1 ) { - return name; - } - return name.substring( lastIndexOf + 1 ); - } - - void sortFiles() { - Comparator comparator = new Comparator() { - @Override - public int compare( ReportModelFile o1, ReportModelFile o2 ) { - return o1.model.getClassName().compareTo( o2.model.getClassName() ); - } - }; - Collections.sort( files, comparator ); - } - - void sortPackages() { - Comparator comparator = new Comparator() { - @Override - public int compare( PackageToc o1, PackageToc o2 ) { - return o1.name.compareTo( o2.name ); - } - }; - Collections.sort( packages, comparator ); - } - - void sort() { - sortFiles(); - sortPackages(); - } - - } - - public PackageToc getRootPackageToc() { - calculatePackageTocs(); - - // ensure that there is at least the root node - getOrCreate( "" ); - - Queue tocCopy = Queues.newArrayDeque( tocs.values() ); - Map handledTocs = Maps.newHashMap(); - - while( !tocCopy.isEmpty() ) { - PackageToc toc = tocCopy.remove(); - if( !toc.name.equals( "" ) ) { - PackageToc parentToc = getOrCreate( toc.getParentName() ); - parentToc.packages.add( toc ); - handledTocs.put( toc.name, toc ); - if( !handledTocs.containsKey( parentToc.name ) ) { - tocCopy.add( parentToc ); - handledTocs.put( parentToc.name, parentToc ); - } - } - - } - - for( PackageToc toc : tocs.values() ) { - toc.sort(); - } - - return tocs.get( "" ); - } - - private void calculatePackageTocs() { - for( ReportModelFile file : sortedModels ) { - String packageName = file.model.getPackageName(); - PackageToc packageToc = getOrCreate( packageName ); - packageToc.files.add( file ); - } - } - - private PackageToc getOrCreate( String packageName ) { - PackageToc packageToc = tocs.get( packageName ); - if( packageToc == null ) { - packageToc = new PackageToc(); - packageToc.name = packageName; - tocs.put( packageName, packageToc ); - } - return packageToc; - } - -} diff --git a/jgiven-core/src/main/java/com/tngtech/jgiven/report/html/ReportModelHtmlWriter.java b/jgiven-core/src/main/java/com/tngtech/jgiven/report/html/ReportModelHtmlWriter.java deleted file mode 100644 index c242a51cfb..0000000000 --- a/jgiven-core/src/main/java/com/tngtech/jgiven/report/html/ReportModelHtmlWriter.java +++ /dev/null @@ -1,206 +0,0 @@ -package com.tngtech.jgiven.report.html; - -import static java.lang.String.format; - -import java.io.*; -import java.text.DateFormat; -import java.util.Date; - -import com.google.common.base.Charsets; -import com.google.common.base.Function; -import com.google.common.base.Strings; -import com.google.common.base.Throwables; -import com.google.common.io.Files; -import com.tngtech.jgiven.impl.util.PrintWriterUtil; -import com.tngtech.jgiven.impl.util.ResourceUtil; -import com.tngtech.jgiven.impl.util.Version; -import com.tngtech.jgiven.report.model.*; - -public class ReportModelHtmlWriter extends ReportModelVisitor { - protected final PrintWriter writer; - protected final HtmlWriterUtils utils; - private ReportStatistics statistics; - private ReportModel reportModel; - - public ReportModelHtmlWriter( PrintWriter writer ) { - this.writer = writer; - utils = new HtmlWriterUtils( writer ); - } - - public void writeHtmlHeader( String title ) { - utils.writeHtmlHeader( title ); - writer.write( "
    " ); - } - - public void writeHtmlFooter() { - writer.println( "
    " ); - writer.println( "" ); - writer.println( "
  • " ); - writeJGivenFooter(); - writer.println( "" ); - writer.println( "" ); - } - - private void writeJGivenFooter() { - writer.print( "" ); - } - - public void write( ScenarioModel model ) { - writeHtmlHeader( model.getClassName() ); - model.accept( this ); - writeHtmlFooter(); - } - - public void write( ReportModel model, HtmlTocWriter htmlTocWriter ) { - writeHtmlHeader( model.getClassName() ); - if( htmlTocWriter != null ) { - htmlTocWriter.writeToc( writer ); - } - model.accept( this ); - writeHtmlFooter(); - - } - - private void writeStatistics( ReportModel model ) { - if( !model.getScenarios().isEmpty() ) { - statistics = new StatisticsCalculator().getStatistics( model ); - writer.print( "
    " ); - writer.print( statistics.numScenarios + " scenarios, " - + statistics.numCases + " cases, " - + statistics.numSteps + " steps, " - + statistics.numFailedCases + " failed cases " ); - utils.writeDuration( statistics.durationInNanos ); - closeDiv(); - } - } - - ReportStatistics getStatistics() { - return statistics; - } - - public static String toString( final ScenarioModel model ) { - return toString( new Function() { - @Override - public Void apply( PrintWriter input ) { - new ReportModelHtmlWriter( input ).write( model ); - return null; - } - } ); - } - - public static String toString( final ReportModel model ) { - return toString( new Function() { - @Override - public Void apply( PrintWriter input ) { - new ReportModelHtmlWriter( input ).write( model, null ); - return null; - } - } ); - } - - public static String toString( Function writeFunction ) { - ByteArrayOutputStream stream = new ByteArrayOutputStream(); - PrintWriter printWriter = null; - - try { - printWriter = new PrintWriter( new OutputStreamWriter( stream, Charsets.UTF_8.name() ), false ); - writeFunction.apply( printWriter ); - printWriter.flush(); - return stream.toString( Charsets.UTF_8.name() ); - } catch( UnsupportedEncodingException e ) { - throw Throwables.propagate( e ); - } finally { - ResourceUtil.close( printWriter ); - } - } - - public static void writeToFile( File file, ReportModel model, HtmlTocWriter htmlTocWriter ) throws FileNotFoundException, - UnsupportedEncodingException { - PrintWriter printWriter = new PrintWriter( file, Charsets.UTF_8.name() ); - try { - new ReportModelHtmlWriter( printWriter ).write( model, htmlTocWriter ); - printWriter.flush(); - } finally { - ResourceUtil.close( printWriter ); - } - } - - @Override - public void visit( ReportModel reportModel ) { - this.reportModel = reportModel; - writer.println( "
    " ); - writeHeader( reportModel ); - writer.println( "
    " ); - if( !reportModel.getScenarios().isEmpty() ) { - writer.println( "" ); - writer.println( "" ); - writer.println( "" ); - } - } - - void writeHeader( ReportModel reportModel ) { - writer.println( " " ); - writer.println( "
    " ); - } - - @Override - public void visit( ScenarioModel scenarioModel ) { - ScenarioHtmlWriter scenarioHtmlWriter; - if( scenarioModel.isCasesAsTable() ) { - scenarioHtmlWriter = new DataTableScenarioHtmlWriter( writer, reportModel ); - } else { - scenarioHtmlWriter = new MultiCaseScenarioHtmlWriter( writer, reportModel ); - } - scenarioModel.accept( scenarioHtmlWriter ); - } - - static ReportModelHtmlWriter writeModelToFile( ReportModel model, HtmlTocWriter tocWriter, File file ) { - PrintWriter printWriter = PrintWriterUtil.getPrintWriter( file ); - try { - ReportModelHtmlWriter htmlWriter = new ReportModelHtmlWriter( printWriter ); - htmlWriter.write( model, tocWriter ); - return htmlWriter; - } finally { - ResourceUtil.close( printWriter ); - } - - } - -} diff --git a/jgiven-core/src/main/java/com/tngtech/jgiven/report/html/ScenarioHtmlWriter.java b/jgiven-core/src/main/java/com/tngtech/jgiven/report/html/ScenarioHtmlWriter.java deleted file mode 100644 index 6f275fd53e..0000000000 --- a/jgiven-core/src/main/java/com/tngtech/jgiven/report/html/ScenarioHtmlWriter.java +++ /dev/null @@ -1,275 +0,0 @@ -package com.tngtech.jgiven.report.html; - -import static com.tngtech.jgiven.report.model.ExecutionStatus.FAILED; -import static com.tngtech.jgiven.report.model.ExecutionStatus.SUCCESS; -import static java.lang.String.format; - -import java.io.PrintWriter; -import java.util.List; - -import com.google.common.html.HtmlEscapers; -import com.tngtech.jgiven.annotation.Table.HeaderType; -import com.tngtech.jgiven.impl.util.WordUtil; -import com.tngtech.jgiven.report.model.*; - -public class ScenarioHtmlWriter extends ReportModelVisitor { - final PrintWriter writer; - final ReportModel reportModel; - - ScenarioModel scenarioModel; - ScenarioCaseModel scenarioCase; - HtmlWriterUtils utils; - - public ScenarioHtmlWriter(PrintWriter writer, ReportModel reportModel) { - this.writer = writer; - this.reportModel = reportModel; - this.utils = new HtmlWriterUtils(writer); - - } - - @Override - public void visit(ScenarioModel scenarioModel) { - this.scenarioModel = scenarioModel; - writer.println("
    "); - - String id = scenarioModel.getClassName() + ":" + scenarioModel.getDescription(); - - writer.print(format("

    ", id)); - - writeStatusIcon(scenarioModel.getExecutionStatus()); - - writer.print(""); - writer.print(" " + WordUtil.capitalize(scenarioModel.getDescription())); - writer.print(""); - - int numberOfCases = scenarioModel.getScenarioCases().size(); - if (numberOfCases > 1) { - writer.print("" + numberOfCases + ""); - } - utils.writeDuration(scenarioModel.getDurationInNanos()); - - writer.println("

    "); - - writeTagLine(scenarioModel); - writer.println(" "); - writer.println("
    "); - } - - @Override - public void visit(ScenarioCaseModel scenarioCase) { - this.scenarioCase = scenarioCase; - printCaseHeader(scenarioCase); - - if (hasMultipleExplicitCases()) { - writer.println(""); - } - writer.println("
    "); - } - - @Override - public void visit(StepModel stepModel) { - writer.print("
  • "); - - boolean firstWord = true; - for (Word word : stepModel.words) { - if (!firstWord) { - writer.print(' '); - } - - if (word.isDataTable()) { - writeDataTable(word); - } else { - String text = HtmlEscapers.htmlEscaper().escape(word.getValue()); - String diffClass = diffClass(word); - if (firstWord && !word.isIntroWord()) { - writer.print(""); - } - - if (firstWord && word.isIntroWord()) { - writer.print(format("%s", WordUtil.capitalize(text))); - } else if (word.isArg()) { - printArg(word); - } else { - if (word.isDifferent()) { - writer.print(format(" %s", diffClass, text)); - } else { - writer.print(" " + text + ""); - } - } - } - firstWord = false; - } - - StepStatus status = stepModel.getStatus(); - if (status != StepStatus.PASSED) { - String lowerCase = status.toString().toLowerCase(); - writer.print(format(" %s", WordUtil.camelCase(lowerCase), lowerCase.replace('_', ' '))); - } - - if (stepModel.hasExtendedDescription()) { - String extendedId = "extDesc" + System.identityHashCode(stepModel); - if (stepModel.hasExtendedDescription()) { - writer.print(" i"); - } - - utils.writeDuration(stepModel.getDurationInNanos()); - writeExtendedDescription(stepModel, extendedId); - } else { - utils.writeDuration(stepModel.getDurationInNanos()); - } - writer.println("
  • "); - } - - private void writeDataTable(Word word) { - writer.println(""); - - boolean firstRow = true; - DataTable dataTable = word.getArgumentInfo().getDataTable(); - HeaderType headerType = dataTable.getHeaderType(); - for (List row : dataTable.getData()) { - writer.println(""); - - boolean firstColumn = true; - for (String value : row) { - boolean th = firstRow && headerType.isHorizontal() || firstColumn && headerType.isVertical(); - writer.println(th ? ""); - firstColumn = false; - } - - writer.println(""); - firstRow = false; - } - - writer.println("
    " : ""); - - String escapedValue = escapeToHtml(value); - String multiLine = value.contains("
    ") ? " multiline" : ""; - writer.print(format("%s", multiLine, escapedValue)); - - writer.println(th ? "" : "
    "); - } - - private void writeExtendedDescription(StepModel stepModel, String id) { - writer.write(""); - } - - private String diffClass(Word word) { - return word.isDifferent() ? " diff" : ""; - } - - private void printArg(Word word) { - String value = word.getArgumentInfo().isParameter() ? formatValue(word) : HtmlEscapers.htmlEscaper().escape( - word.getFormattedValue()); - printArgValue(word, value); - } - - private void printArgValue(Word word, String value) { - value = escapeToHtml(value); - String multiLine = value.contains("
    ") ? " multiline" : ""; - String caseClass = word.getArgumentInfo().isParameter() ? "caseArgument" : "argument"; - writer.print(format("%s", caseClass, multiLine, diffClass(word), value)); - } - - private String escapeToHtml(String value) { - return value.replaceAll("(\r\n|\n)", "
    "); - } - - String formatValue(Word word) { - return HtmlEscapers.htmlEscaper().escape(word.getValue()); - } -} diff --git a/jgiven-core/src/main/java/com/tngtech/jgiven/report/html/StaticHtmlReportGenerator.java b/jgiven-core/src/main/java/com/tngtech/jgiven/report/html/StaticHtmlReportGenerator.java deleted file mode 100644 index badd1ed425..0000000000 --- a/jgiven-core/src/main/java/com/tngtech/jgiven/report/html/StaticHtmlReportGenerator.java +++ /dev/null @@ -1,106 +0,0 @@ -package com.tngtech.jgiven.report.html; - -import java.io.*; -import java.util.List; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.io.ByteStreams; -import com.google.common.io.Files; -import com.tngtech.jgiven.impl.util.ResourceUtil; -import com.tngtech.jgiven.report.AbstractReportGenerator; -import com.tngtech.jgiven.report.html.PackageTocBuilder.PackageToc; -import com.tngtech.jgiven.report.model.ReportModel; -import com.tngtech.jgiven.report.model.ReportModelFile; -import com.tngtech.jgiven.report.model.ScenarioModel; -import com.tngtech.jgiven.report.model.Tag; - -public class StaticHtmlReportGenerator extends AbstractReportGenerator { - private static final Logger log = LoggerFactory.getLogger( StaticHtmlReportGenerator.class ); - - @Override - public void generate() { - writeEnd(); - copyFileToTargetDir( "style.css" ); - copyFileToTargetDir( "default.css" ); - copyFileToTargetDir( "print.css" ); - copyFileToTargetDir( "report.js" ); - copyFileToTargetDir( "fontawesome.css" ); - copyFileToTargetDir( "fontawesome.ttf" ); - } - - protected void copyFileToTargetDir( String fileName ) { - InputStream stream = null; - FileOutputStream fileOutputStream = null; - try { - stream = this.getClass().getResourceAsStream( "/com/tngtech/jgiven/report/html/" + fileName ); - File file = new File( targetDirectory, fileName ); - fileOutputStream = new FileOutputStream( file ); - ByteStreams.copy( stream, fileOutputStream ); - } catch( FileNotFoundException e ) { - e.printStackTrace(); - } catch( IOException e ) { - e.printStackTrace(); - } finally { - ResourceUtil.close( stream, fileOutputStream ); - } - } - - public void writeEnd() { - PackageToc packageToc = new PackageTocBuilder( completeReportModel.getAllReportModels() ).getRootPackageToc(); - HtmlTocWriter tocWriter = new HtmlTocWriter( completeReportModel, packageToc ); - - for( ReportModelFile modelFile : completeReportModel.getAllReportModels() ) { - String targetFileName = Files.getNameWithoutExtension( modelFile.file.getName() ) + ".html"; - File targetFile = new File( targetDirectory, targetFileName ); - - ReportModelHtmlWriter modelWriter = ReportModelHtmlWriter.writeModelToFile( modelFile.model, tocWriter, targetFile ); - } - - writeTagFiles( tocWriter ); - writeScenarios( tocWriter, completeReportModel.getFailedScenarios(), "Failed Scenarios", "failed.html" ); - writeScenarios( tocWriter, completeReportModel.getPendingScenarios(), "Pending Scenarios", "pending.html" ); - writeScenarios( tocWriter, completeReportModel.getAllScenarios(), "All Scenarios", "all.html" ); - - StatisticsPageHtmlWriter statisticsPageHtmlWriter = new StatisticsPageHtmlWriter( tocWriter, - completeReportModel.getTotalStatistics() ); - statisticsPageHtmlWriter.write( targetDirectory ); - - } - - private void writeScenarios( HtmlTocWriter tocWriter, List scenarios, String name, String fileName ) { - ReportModel reportModel = new ReportModel(); - reportModel.setScenarios( scenarios ); - reportModel.setClassName( name ); - reportModel.setTagMap( this.completeReportModel.getTagIdMap() ); - ReportModelHtmlWriter.writeModelToFile( reportModel, tocWriter, new File( targetDirectory, fileName ) ); - } - - private void writeTagFiles( HtmlTocWriter tocWriter ) { - for( Tag tag : completeReportModel.getAllTags() ) { - writeTagFile( tag, completeReportModel.getScenariosByTag( tag ), tocWriter ); - } - } - - private void writeTagFile( Tag tag, List value, HtmlTocWriter tocWriter ) { - try { - ReportModel reportModel = new ReportModel(); - reportModel.setClassName( tag.getName() ); - if( tag.getValues().isEmpty() ) { - reportModel.setClassName( reportModel.getClassName() + "." + tag.getValueString() ); - } - reportModel.setScenarios( value ); - reportModel.setDescription( tag.getDescription() ); - reportModel.setTagMap( completeReportModel.getTagIdMap() ); - - String fileName = HtmlTocWriter.tagToFilename( tag ); - File targetFile = new File( targetDirectory, fileName ); - ReportModelHtmlWriter.writeToFile( targetFile, reportModel, tocWriter ); - - } catch( Exception e ) { - log.error( "Error while trying to write HTML file for tag " + tag.getName(), e ); - } - } - -} 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 deleted file mode 100644 index e4df010163..0000000000 --- a/jgiven-core/src/main/java/com/tngtech/jgiven/report/html/StatisticsPageHtmlWriter.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.tngtech.jgiven.report.html; - -import java.io.File; -import java.io.PrintWriter; - -import com.tngtech.jgiven.report.util.DurationFormatter; -import com.tngtech.jgiven.impl.util.PrintWriterUtil; -import com.tngtech.jgiven.impl.util.ResourceUtil; -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 = PrintWriterUtil.getPrintWriter( file ); - utils = new HtmlWriterUtils( printWriter ); - try { - ReportModelHtmlWriter htmlWriter = new ReportModelHtmlWriter( printWriter ); - htmlWriter.writeHtmlHeader( "Summary" ); - - ReportModel reportModel = new ReportModel(); - reportModel.setClassName( ".Summary" ); - - tocWriter.writeToc( printWriter ); - htmlWriter.visit( reportModel ); - - writeStatistics(); - - htmlWriter.visitEnd( reportModel ); - htmlWriter.writeHtmlFooter(); - } finally { - ResourceUtil.close( printWriter ); - } - } - - private void writeStatistics() { - printWriter.write( "
    " ); - writeStatisticNumber( statistics.numClasses, "classes" ); - - writeStatisticsNumberWithLink( statistics.numScenarios, "scenarios", "all.html" ); - - writeStatisticNumber( statistics.numCases, "cases" ); - writeStatisticNumber( statistics.numSteps, "steps" ); - - writeStatisticsNumberWithLink( statistics.numPendingScenarios, "pending scenarios", "pending.html" ); - - String failedClass = statistics.numFailedScenarios > 0 ? "failed" : ""; - printWriter.write( "" ); - - writeStatisticNumber( DurationFormatter.format( statistics.durationInNanos ), "total time" ); - long averageNanos = statistics.numCases != 0 ? statistics.durationInNanos / statistics.numCases : 0; - writeStatisticNumber( DurationFormatter.format( averageNanos ), "time / case" ); - printWriter.println( "
    " ); - } - - private void writeStatisticsNumberWithLink( int number, String title, String fileName ) { - printWriter.write( "" ); - } - - private void writeStatisticNumber( int number, String name ) { - writeStatisticNumber( number + "", name ); - } - - private void writeStatisticNumber( String number, String name ) { - 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 deleted file mode 100644 index 16ac3df3a6..0000000000 --- a/jgiven-core/src/main/resources/com/tngtech/jgiven/report/html/default.css +++ /dev/null @@ -1,779 +0,0 @@ -@media all and (min-width: 800px) { - #col-container { - display: table; - } - - #leftpane { - display: table-cell; - vertical-align: top; - border-right: 1px solid #ddd; - } - - #rightpane { - display: table-cell; - vertical-align: top; - width:100%; - } - - #content { - display: inline-block; - } -} - -@media all and (max-width: 800px) { - #rightpane { - margin-left: 10px; - } -} - -html, body { - height: 100%; -} - -html { - margin: 0; - padding: 0; - box-sizing: border-box; -} - -body { - padding: 0px; - font: 14px "Open Sans", "Lucida Grande", Helvetica, Arial, sans-serif; - background-color: #aaa; - margin: 0; -} - -*, *:before, *:after { - box-sizing: inherit; -} - -a { - text-decoration: none; -} - -a:hover { - text-decoration: underline; -} - -a#toggle-btn { - color: gray; - text-decoration: none; - display:block; - text-align:right; - font-weight: bold; - padding-right: 1ex; - padding-left: 1ex; -} - -a#toggle-btn:hover { - background-color: lightgray; -} - -h1 { - background-color: #fff; - padding:10px; - color: #555; - font-size: 32px; - font-weight: 300; - margin-top: 0; - padding-bottom:0; -} - -h2, h2 a { - font-size: 32px; - color: white; - font-weight: 600; - margin:0px; - border-radius:0; - padding-top:5px; - padding-bottom: 15px; - padding-left: 20px; - display: inline-block; - float: left; -} - -#content-search-input { - margin-bottom: 10px; -} - -#toc { - font-size: 20px; - padding: 10px; - margin: 0px; - min-width: 10em; -} - -#toc-container { - height: 100%; -} - -#toc ul { - list-style-type: none; - padding:0px; - padding-left:10px; - margin:0px; - white-space-collapsing:discard; - font-size:0px; -} - -#toc > ul { - margin-top: 5px; - padding: 10px; - padding-top: 0px; - padding-bottom: 0px; -} - -#toc ul li { - padding-top:3px; - padding-bottom:0px; - margin-top:0px; - margin-bottom:0px; - font-size: 14px; - line-height: 1.25; -} - -#toc ul li a { - text-decoration: none; - color: #000066; - font-size: 14px; -} - -#toc ul h4 { - color: #444; - padding:0; - margin:0; - font-weight: normal; - cursor: pointer; -} - -#toc-search-input { - margin-left: 10px; - margin-top: 5px; - width: 90%; -} - -.search-input, .search-input:focus { - border: 1px solid gray; - border-radius: 15px; - font-size: 12px; - padding: 3px 8px; -} - -.search-input:focus { - outline: none; - box-shadow: 0px 0px 3px blue; -} - -h1 { - background: #444; - padding-top:30px; - padding-bottom:23px; - margin-bottom: 25px; - border-bottom: 1px solid lightgray; - color: #f0f0f0; -} - -#toc { - position:relative; -} - -#toc h3 { - margin:0px; - margin-top: 10px; - padding-left: 10px; - padding-top: 5px; - padding-bottom: 0px; -} - -#toc h3, #toc h3 a { - font-size: 14px; - color: #444; - text-shadow: 1px 1px 1px #fff; -} - -#toc > .icon-cancel { - position: absolute; - top: 2px; - right: 2px; - color: gray; - font-size: 12px; - cursor: pointer; -} - -#toc .icon-cancel:hover { - color: lightgray; -} - -#show-menu-icon { - position: absolute; - top: 3px; - left: 3px; - cursor: pointer; - color: lightgray; - font-size: 12px; -} - -#show-menu-icon:hover { - color: white; -} - - -.package { - font-size: 70%; -} - -.packagename { - font-size: 15px; - font-weight: bold; - color: white; - padding-left: 20px; - padding-top: 10px; -} - -#page { - margin:0; - box-shadow: 0px 0px 15px #222; - background-color:white; -} - -#leftpane { - padding: 0px; - margin: 0px; - background-color: #efefef; -} - -#page-footer { - clear:both; - height:0px; -} - -#footer, -#footer a { - color: #333; - text-shadow: 0px 1px 0px #ddd; - text-decoration: none; - clear: both; -} - -#footer { - margin: auto; - text-align: center; - padding: 10px; -} - -#rightpane { - margin:0px; - margin-bottom: 0px; - padding: 0px; - background: white; -} - -#content { - padding: 20px; - background: white; -} - -#header { - position: relative; - background-color: #f0f0f0; - background: #444; - background: #4B5389; - background-color: rgb(58, 88, 130); - /* box-shadow: 2px 2px 5px gray; */ - border-bottom: 1px solid lightgray; -} - -#header-title:after { - content: ""; - display: table; - clear: both; -} - -#header .description { - font-size: 18px; - padding-top:10px; - color: white; - color: black; - background-color: rgb(255, 255, 239); - padding: 20px; -} - -#expand-all-icon, #collapse-all-icon { - cursor: pointer; - float: right; -} - -#content > ul { - list-style-type: none; - padding-left:0px; - padding-right:10px; - padding-top:0px; - padding-bottom:10px; -} - -.scenarioClassName { - font-size: 14px; - color:#666; - padding-left: 5px; - padding-bottom: 2px; - text-align: right; - padding-right: 5px; - border-top: lightgray solid 1px; - -} - -.scenario ul { - list-style-type: none; -} -.scenarioHeader { - padding-left: 10px; - padding-bottom: 15px; -} - -.scenario { - position: relative; - margin: 0px; - padding: 0px; - border-radius: 0px; - padding-bottom:15px; - margin-bottom:15px; - background-color: white; - min-height: 5px; - clear: both; -} - -.scenario-body { - border-bottom: lightgray solid 1px; -} - -.scenario-content { - clear: both; - margin-left: 0px; - margin-right: 0px; - padding-bottom: 5px; - padding-top: 5px; - margin-bottom: 0px; - background-color: white; -} - -.scenario h3 { - vertical-align: middle; - margin-top: 8px; - margin-top: 8px; - margin-bottom: 0px; - margin-left:0px; - margin-right: 0px; - overflow:hidden; - padding-top: 0px; - padding-left: 0px; - padding-right: 1ex; - padding-bottom: 0px; - background-color: white; - float: left; -} - -.scenario h3, .scenario h3 a { - font-weight: bold; - font-size: 16px; - color: black; - cursor: pointer; -} - -.icon-ok { - color: green; -} - -.icon-cancel { - color: red; -} - -.case { - padding-left: 0px; - padding-right: 0px; - padding-bottom: 0px; - padding-top: 0px; - margin-bottom: 0px; - position:relative; -} - -.passedCase ul.steps { - background-color: rgba(0, 139, 69, 0.1); - background-color: #E9FFE9; - background-color: #f6f6f6; - background-color: white; -} - -.failedCase ul.steps { - background-color: #FEE; - background-color: white; -} - -.notImplementedCase { - background-color: #ddd; -} - -.partiallyImplementedCase { - background-color: #ffb; -} - -.tag-line { - margin-top: 4px; - vertical-align: middle; - float: right; - opacity: 0.9; -} - -.tag { - vertical-align: middle; - font-size: 14px; - font-weight: normal; - color: rgba(0, 0, 0, 0.9); - margin-right:0; - border-radius: 0px; - text-shadow: none; - margin-left: 1ex; - margin-right: 5px; - margin-top: 5px; - display: inline-block; - border-radius: 4px; - background-color: violet; -} - -.tag a { - display: inline-block; - text-decoration: none; - font-size: 14px; - color: rgba(0, 0, 0, 0.9); - padding-bottom:1px; - padding-top: 0px; - padding-left: 4px; - padding-right: 4px; -} - -.tag a:hover { - background-color: rgba(255,255,255,0.5); -} - -.tag-NotImplementedYet { - background-color: gray; - border-color: darkgray; -} - -.failed { - background-color: #f44; - border: #f44 solid 3px; - border-radius: 5px; - margin-bottom: 5px; - font-weight:bold; - font-size: 16px; - color: rgba(0, 0, 0, 0.7); - text-shadow: none; -} - -.badge.failed { - border: 2px; -} - -.topRight { - position: absolute; - right:1em; - top:1em; -} - -.passed, .badge, .notImplementedYet, .partiallyPassed { - border-radius: 3px; - display:inline; - color: rgba(0, 0, 0, 0.6); - font-weight:bold; - font-size: 12px; - padding: 1px; - padding-left:8px; - padding-right:8px; - vertical-align: middle; - margin-left: 1em; - margin-right: 1em; -} - -.badge { - position: relative; - top: -1px; -} - -.passed { - background-color: lightgreen; - border-color: lightgreen; - margin-left: 0; - margin-right: 0; -} - -.partiallyPassed { - background-color: khaki; - border-color: khaki; -} - -.notImplementedYet, .skipped { - background-color: #777; - border-color: #777; - color: rgb(245, 245, 245); -} - -.notImplementedYetTag { - background-color: #777; - border: #777 solid 3px; - border-radius: 3px; - display:inline; - font-size: 10px; - color: rgba(255, 255, 255, 0.6); - margin-left:1em; - vertical-align: middle; -} - -.count { - background-color: #aaa; - color: white; - border-radius: 7px; - font-size: 10px; - margin-right: 0em; - margin-left: 0.5em; - background-color: gray; -} - -.stages { - margin: 0; - margin-top: 10px; - padding: 0; - padding-bottom: 5px; - font-size:18px; -} - -.stagetype { - float: left; - width:3em; -} - -ul.steps { - list-style-type: none; - margin-left: 0; - margin-top: 0; - margin-bottom: 0px; - padding: 10px; - padding-left: 18px; - padding-botom:0px; - position:relative; - font-size:16px; -} - -.collapsed { - display:none; -} - -ul.steps li { - padding-bottom:1px; -} - -.introWord { - display: inline-block; - min-width: 3em; - text-align: right; - color: black; -} - -.caseArgument { - color: midnightblue; - font-weight:bold; -} - -.argument { - color: darkmagenta; -} - -.multiline { - font-family: monospace; - border: 1px solid lightgray; - background-color: white; - display: table; - white-space: pre; - margin: 5px; - margin-left: 3.3em; -} - -.steps .data-table { - margin-left: 3.3em; -} - -.diff { - background-color: rgb(207, 237, 247); - padding: 0 5px 0 5px; - border-radius: 2px; -} - -.highlight { - background-color: yellow; -} - -.show-extended-description { - padding: 1px; - padding-left:4px; - padding-right:4px; - border: 1px solid gray; - border-radius: 10px; - color: gray; - font-weight: bold; - min-width: 20px; - cursor: pointer; - font-size: 10px; - font-family: monospace; - vertical-align: middle; -} - -.show-extended-description:hover { - color: #222; - border-color: #222; -} - -.extended-description-content { - position: relative; - color: #222; - background-color: rgb(207, 237, 247); - border-radius: 3px; - box-shadow: 0px 0px 2px lightgray; - padding: 7px; - padding-right: 20px; - margin-left: 1em; - margin-bottom: 5px; - font-size: 14px; - font-style: italic; - display: inline-block; -} - -.extended-description .icon-cancel { - position: absolute; - right: 0px; - top: 0px; - color: #aaa; - cursor: pointer; -} - -.scenario h4 { - color: #333; - font-weight: bold; - font-size: 15px; - padding: 0px; - padding-left: 5px; - margin-bottom: 0px; - margin-left: 10px; - margin-top: 0px; - text-shadow: 1px 1px 1px #eee; - cursor: pointer; - -} - -.scenario h5 { - color: #333; - margin-bottom: 0; - margin-top: 0; - padding-left:10px - font-size: 18px; - font-weight: normal; -} - -.data-table { - margin-top: 10px; - margin-bottom: 15px; - margin-left: 20px; - border: 1px solid lightgray; - border-collapse:collapse; - background-color: white; -} - -.data-table th, .data-table td { - border: 1px solid lightgray; -} - -.data-table td { - padding: 10px; -} - -.data-table th { - background-color: #444; - color: white; - padding: 8px; -} - -.data-table tr:nth-child(odd) { - background-color: #eee; -} - -.scenario-footer { - clear: both; - text-align:right; - padding:5px; - padding-right:5px; - padding-bottom:5px; - padding-top:0px; - margin:0; - margin-right:0px; - margin-left:0px; - margin-top: 0px; -} - -.scenario-footer a { - text-decoration: none; - color: #888; - font-size: 14px; - padding: 5px; -} - -.statistics { - padding-top:10px; -} - -.statistics-number { - padding: 20px; - border: solid #e0e0e0 1px; - border-radius: 20px; - display: inline-block; - margin-right: 20px; - margin-bottom: 20px; - text-align: center; - background-color: #f0f0f0; -} - -.statistics-number a { - display: inline-block; -} - -.statistics-number.failed { - background-color: #f0f0f0; -} - -.statistics-number.failed a { - color: red; -} - -.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; -} diff --git a/jgiven-core/src/main/resources/com/tngtech/jgiven/report/html/fontawesome.css b/jgiven-core/src/main/resources/com/tngtech/jgiven/report/html/fontawesome.css deleted file mode 100644 index 1433f56d58..0000000000 --- a/jgiven-core/src/main/resources/com/tngtech/jgiven/report/html/fontawesome.css +++ /dev/null @@ -1,34 +0,0 @@ -@font-face { - font-family: 'fontawesome'; - src: url('fontawesome.ttf'); - font-weight: normal; - font-style: normal; -} - - [class^="icon-"]:before, [class*=" icon-"]:before { - font-family: "fontawesome"; - font-style: normal; - font-weight: normal; - speak: none; - - display: inline-block; - text-decoration: inherit; - width: 1em; - margin-right: .2em; - text-align: center; - - font-variant: normal; - text-transform: none; - - line-height: 1em; -} - -.icon-plus-squared-alt:before { content: '\e800'; } /* '' */ -.icon-minus-squared-alt:before { content: '\e801'; } /* '' */ -.icon-attention-alt:before { content: '\e802'; } /* '' */ -.icon-ok:before { content: '\e803'; } /* '' */ -.icon-right-open:before { content: '\e804'; } /* '' */ -.icon-down-open:before { content: '\e805'; } /* '' */ -.icon-block:before { content: '\e806'; } /* '' */ -.icon-cancel:before { content: '\e807'; } /* '' */ -.icon-menu:before { content: '\e808'; } /* '' */ diff --git a/jgiven-core/src/main/resources/com/tngtech/jgiven/report/html/fontawesome.ttf b/jgiven-core/src/main/resources/com/tngtech/jgiven/report/html/fontawesome.ttf deleted file mode 100644 index 8f1adb8d59..0000000000 Binary files a/jgiven-core/src/main/resources/com/tngtech/jgiven/report/html/fontawesome.ttf and /dev/null differ diff --git a/jgiven-core/src/main/resources/com/tngtech/jgiven/report/html/print.css b/jgiven-core/src/main/resources/com/tngtech/jgiven/report/html/print.css deleted file mode 100644 index 2d245ccfce..0000000000 --- a/jgiven-core/src/main/resources/com/tngtech/jgiven/report/html/print.css +++ /dev/null @@ -1,41 +0,0 @@ -.tag, .passed { - -webkit-print-color-adjust:exact; -} - -#header { - background-color: white; - -webkit-print-color-adjust:exact; -} - -h2, .packagename, #header .description { - color: black; -} - - -#leftpane, -.search-input, -.extended-description-content, -.show-extended-description, -#show-menu-icon { - display: none; -} - -#header .description { - background: none; -} - -.scenario h3 { - font-size: 12pt; -} - -ul.steps { - font-size: 10pt; -} - -.scenario-footer a { - font-size: 8pt; -} - -.collapsed { - display: block; -} diff --git a/jgiven-core/src/main/resources/com/tngtech/jgiven/report/html/report.js b/jgiven-core/src/main/resources/com/tngtech/jgiven/report/html/report.js deleted file mode 100644 index 4b3372b6e1..0000000000 --- a/jgiven-core/src/main/resources/com/tngtech/jgiven/report/html/report.js +++ /dev/null @@ -1,257 +0,0 @@ -init(); - -var SEARCH_TIMEOUT = 250; -var MAX_HITS = 100; - -function init() { - if (document.location.search.indexOf('toc=0') != -1) { - hideToc(); - } -} - -function showToc() { - toggle('toc'); - toggle('show-menu-icon'); - adaptHrefs(false); -} - -function hideToc() { - toggle('toc'); - toggle('show-menu-icon'); - adaptHrefs(true); -} - -function adaptHrefs(hideToc) { - var elements = document.getElementsByTagName("A"); - for (i = 0; i < elements.length; i++) { - var href = elements[i].getAttribute('href'); - - var newHref; - if (hideToc) { - newHref = href + "?toc=0"; - } else { - newHref = href.replace("?toc=0",""); - } - - elements[i].setAttribute('href', newHref); - } -} - -/** - * Invoked when the use clicks on the header of a collapsibel element - * @param id - */ -function toggle(id) { - var element = document.getElementById(id); - toggleElement(element); -} - -function toggleElement(element) { - if (!element.classList) { - return; - } - - if (element.classList.toggle) { - element.classList.toggle('collapsed'); - } else { - if (element.style.display === 'block') { - element.style.display = 'none'; - } else { - element.style.display = 'block'; - } - } -} - -function isCollapsed(element) { - if (!element.classList) { - return false; - } - - if (element.classList.toggle){ - return element.classList.contains('collapsed'); - } - - return element.style.display === 'none'; -} - -var searchTimeout; - -/** - * Invoked when the content of the content search field changes - */ -function contentSearchChanged(event) { - if (searchTimeout) { - window.clearTimeout(searchTimeout); - } - - searchTimeout = window.setTimeout( function() { - var content = document.getElementById('content'); - var searchfield = document.getElementById('content-search-input'); - var search = searchfield.value; - console.log("Search for " + search); - openMatchingElements(new RegExp(search,'i'), content, 2, contentElementsToToggle, elementsToBeSearched); - - if (search === '') { - collapseAll(content, 1, contentElementsToBeClosed); - } - }, SEARCH_TIMEOUT); -} - -function contentElementsToToggle(element) { - return element.className === 'scenario-body' - || element.className === 'scenario' - || element.className === 'case-content'; -} - -function tocElementsToToggle(element) { - return element.tagName === "UL" || element.tagName === "LI"; -} - -/** - * Invoked when the content of the TOC search field changes - */ -function searchChanged(event) { - if (searchTimeout) { - window.clearTimeout(searchTimeout); - } - - searchTimeout = window.setTimeout( function() { - var toc = document.getElementById('toc'); - var searchfield = document.getElementById('toc-search-input'); - var search = searchfield.value; - console.log("Search for " + search); - if (search === '') { - collapseAll(toc, 0, ulElement); - } else { - openMatchingElements(new RegExp(search,'i'), toc, 0, tocElementsToToggle, elementsToBeSearched); - } - }, SEARCH_TIMEOUT); -} - -function elementsToBeSearched(element) { - if (element.className) { - return element.className.indexOf('extended-description') === -1; - } - return true; -} - -function contentElementsToBeClosed(element) { - return element.className && (element.className.indexOf('scenario-body') !== -1 - || element.className.indexOf('case-content') !== -1); -} - -function ulElement(element) { - return element.tagName === "UL"; -} - -function expandAllClicked() { - expandAll( document.getElementById('content'), contentElementsToBeClosed ) -} - -function expandAll(element, toBeExpanded) { - if (isCollapsed(element) && toBeExpanded(element)) { - toggleElement(element); - } - - expandChildren(element, toBeExpanded); -} - -function expandChildren(element, toBeExpanded) { - var child = element.firstChild; - while (child) { - expandAll(child, toBeExpanded); - child = child.nextSibling; - } -} - - -function collapseAllClicked() { - collapseAll( document.getElementById('content'), 1, contentElementsToBeClosed); -} - -function collapseAll(element, depth, toBeClosed) { - unhighlight(element); - - if (depth > 2 && toBeClosed(element) && !isCollapsed(element)) { - toggleElement(element); - } - - collapseChildren(element, depth, toBeClosed) -} - -function collapseChildren(element, depth, toBeClosed) { - var child = element.firstChild; - while (child) { - collapseAll(child, depth + 1, toBeClosed); - child = child.nextSibling; - } -} - -function onlyHasTextNode(element) { - return element.childNodes.length === 1 - && element.childNodes[0].nodeType === 3; -} - -function openMatchingElements(search, element, depth, shouldToggleElement, shouldSearchElement) { - if (!shouldSearchElement(element)) { - return false; - } - - if (element.nodeType==3 && element.nodeValue.match(search )) { - return true; - } - - // close element by default, in case it is currently visible - if (depth > 2 && shouldToggleElement(element) && !isCollapsed(element)) { - toggleElement(element); - } - - unhighlight(element); - - var found = 0; - var child = element.firstChild; - while (child && (depth > 2 || found < MAX_HITS)) { - if (openMatchingElements(search, child, depth + 1,shouldToggleElement, shouldSearchElement)) { - found++; - } - child = child.nextSibling; - } - - if (found > 0) { - if (isCollapsed(element)) { - toggleElement(element); - } - highlightMatches(element, search); - } - return found; -} - -function unhighlight(element) { - if (element.getAttribute) { - var originalValue = element.getAttribute("data-original"); - if (originalValue) { - element.innerHTML = originalValue; - element.removeAttribute("data-original"); - } - } -} - -function highlightMatches(element, search) { - if (onlyHasTextNode(element)) { - var origValue = element.innerHTML; - var changedValue = replaceMatches(origValue, search); - if (origValue !== changedValue) { - element.innerHTML = changedValue; - element.setAttribute("data-original", origValue); - } - } -} - -function replaceMatches(text, search) { - var result = text.replace(search, "$&"); - return result; -} - -function showExtendedDescription(id) { - toggle(id); -} diff --git a/jgiven-core/src/main/resources/com/tngtech/jgiven/report/html/style.css b/jgiven-core/src/main/resources/com/tngtech/jgiven/report/html/style.css deleted file mode 100644 index 9845468275..0000000000 --- a/jgiven-core/src/main/resources/com/tngtech/jgiven/report/html/style.css +++ /dev/null @@ -1,4 +0,0 @@ -@import url("fontawesome.css"); -@import url("default.css"); -@import url("print.css") print; -@import url("custom.css"); diff --git a/jgiven-core/src/test/java/com/tngtech/jgiven/report/html/ReportModelHtmlWriterTest.java b/jgiven-core/src/test/java/com/tngtech/jgiven/report/html/ReportModelHtmlWriterTest.java deleted file mode 100644 index b09ce40c9d..0000000000 --- a/jgiven-core/src/test/java/com/tngtech/jgiven/report/html/ReportModelHtmlWriterTest.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.tngtech.jgiven.report.html; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import com.tngtech.java.junit.dataprovider.DataProvider; -import com.tngtech.java.junit.dataprovider.DataProviderRunner; -import com.tngtech.java.junit.dataprovider.UseDataProvider; -import com.tngtech.jgiven.GivenTestStep; -import com.tngtech.jgiven.ThenTestStep; -import com.tngtech.jgiven.WhenTestStep; -import com.tngtech.jgiven.base.ScenarioTestBase; -import com.tngtech.jgiven.report.model.ReportModel; - -@RunWith( DataProviderRunner.class ) -public class ReportModelHtmlWriterTest extends ScenarioTestBase { - - @DataProvider - public static Object[][] testData() { - return new Object[][] { - { 5, 6, 30 }, - { 2, 2, 4 }, - { -5, 1, -5 }, - }; - } - - @Test - @UseDataProvider( "testData" ) - public void HTML_report_is_correctly_generated_for_scenarios( int a, int b, int expectedResult ) throws Throwable { - getScenario().startScenario( "values can be multiplied" ); - - given().$d_and_$d( a, b ); - when().both_values_are_multiplied_with_each_other(); - then().the_result_is( expectedResult ); - - getScenario().finished(); - ReportModel model = getScenario().getModel(); - String string = ReportModelHtmlWriter.toString( model.getLastScenarioModel() ); - assertThat( string.replace( System.getProperty("line.separator"), " ") ).matches( - ".*" - + ".*Values can be multiplied.*.*" - + "
  • Given " + a + ".*and.*" + b + ".*
  • .*" - + "
  • When both values are multiplied with each other.*
  • .*" - + "
  • Then the result is.*" + expectedResult - + ".*
  • .*" - + ".*" ); - } - - @DataProvider - public static Object[][] testArguments() { - return new Object[][] { - { "a", "b" }, - }; - } - -} diff --git a/jgiven-examples/build.gradle b/jgiven-examples/build.gradle index 01ed83fa67..f251043b88 100644 --- a/jgiven-examples/build.gradle +++ b/jgiven-examples/build.gradle @@ -9,7 +9,6 @@ dependencies { testCompile group: 'pl.pragmatists', name: 'JUnitParams', version: junitParamsVersion } -test.finalizedBy(jgivenReport) test.finalizedBy(jgivenHtml5Report) // there is a test that fails on purpose to show a failing test in the report diff --git a/jgiven-java8-tests/build.gradle b/jgiven-java8-tests/build.gradle index 98c624d3c7..e37376e3a1 100644 --- a/jgiven-java8-tests/build.gradle +++ b/jgiven-java8-tests/build.gradle @@ -8,4 +8,4 @@ dependencies { sourceCompatibility = targetCompatibility = 1.8 -test.finalizedBy(jgivenReport) +test.finalizedBy(jgivenHtml5Report) diff --git a/jgiven-junit/build.gradle b/jgiven-junit/build.gradle index 5de4cf8b5c..8a5948ce6f 100644 --- a/jgiven-junit/build.gradle +++ b/jgiven-junit/build.gradle @@ -8,4 +8,4 @@ dependencies { testCompile group: 'pl.pragmatists', name: 'JUnitParams', version: junitParamsVersion } -test.finalizedBy(jgivenReport) +test.finalizedBy(jgivenHtml5Report) diff --git a/jgiven-tests/build.gradle b/jgiven-tests/build.gradle index 1bd97b4bd3..8c1e51fb82 100644 --- a/jgiven-tests/build.gradle +++ b/jgiven-tests/build.gradle @@ -15,6 +15,5 @@ dependencies { testCompile 'org.apache.commons:commons-io:1.3.2' } -test.finalizedBy(jgivenReport) test.finalizedBy(jgivenHtml5Report) test.finalizedBy(jgivenAsciiDocReport) diff --git a/jgiven-tests/src/test/java/com/tngtech/jgiven/report/WhenReportGenerator.java b/jgiven-tests/src/test/java/com/tngtech/jgiven/report/WhenReportGenerator.java index aa3e9f087d..39d38c30db 100644 --- a/jgiven-tests/src/test/java/com/tngtech/jgiven/report/WhenReportGenerator.java +++ b/jgiven-tests/src/test/java/com/tngtech/jgiven/report/WhenReportGenerator.java @@ -12,7 +12,6 @@ import com.tngtech.jgiven.annotation.ScenarioRule; import com.tngtech.jgiven.report.ReportGenerator.Format; import com.tngtech.jgiven.report.asciidoc.AsciiDocReportGenerator; -import com.tngtech.jgiven.report.html.StaticHtmlReportGenerator; import com.tngtech.jgiven.report.json.ReportModelReader; import com.tngtech.jgiven.report.model.CompleteReportModel; import com.tngtech.jgiven.report.text.PlainTextReportGenerator; @@ -46,10 +45,6 @@ protected CompleteReportModel getCompleteReportModel() { return new ReportModelReader().readDirectory( jsonReportDirectory ); } - public void the_static_HTML_reporter_is_executed() throws IOException { - new StaticHtmlReportGenerator().generate( getCompleteReportModel(), targetReportDir ); - } - private void createReportGenerator() { htmlReportGenerator = new ReportGenerator(); htmlReportGenerator.setCustomCssFile( customCssFile ); diff --git a/jgiven-tests/src/test/java/com/tngtech/jgiven/report/html/ReportGeneratorTest.java b/jgiven-tests/src/test/java/com/tngtech/jgiven/report/html/ReportGeneratorTest.java deleted file mode 100644 index 8ca0423a89..0000000000 --- a/jgiven-tests/src/test/java/com/tngtech/jgiven/report/html/ReportGeneratorTest.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.tngtech.jgiven.report.html; - -import org.junit.Test; - -import com.tngtech.jgiven.JGivenScenarioTest; -import com.tngtech.jgiven.report.ReportGenerator; -import com.tngtech.jgiven.report.WhenReportGenerator; -import com.tngtech.jgiven.report.json.GivenJsonReports; -import com.tngtech.jgiven.report.text.ThenPlainTextReportGenerator; -import com.tngtech.jgiven.tags.FeatureHtmlReport; -import com.tngtech.jgiven.tags.FeatureTextReport; - -public class ReportGeneratorTest extends JGivenScenarioTest, WhenReportGenerator, ThenStaticHtmlReportGenerator> { - - @Test - @FeatureHtmlReport - public void the_report_generator_can_generate_HTML_files() throws Exception { - given().a_report_model_as_JSON_file(); - - given().a_custom_CSS_file(); - - when().the_report_generator_is_executed_with_format( ReportGenerator.Format.HTML ); - - then().an_index_file_exists() - .and().the_custom_CSS_file_is_copied_to_the_target_directory() - .and().an_HTML_file_exists_for_each_test_class(); - } - - @Test - @FeatureTextReport - public void the_report_generator_can_generate_text_files() throws Exception { - ThenPlainTextReportGenerator thenPlainText = addStage( ThenPlainTextReportGenerator.class ); - - given().a_report_model_as_JSON_file(); - - when().the_report_generator_is_executed_with_format( ReportGenerator.Format.TEXT ); - - thenPlainText.then() - .a_text_file_exists_for_each_test_class(); - } -} diff --git a/jgiven-tests/src/test/java/com/tngtech/jgiven/report/html/ReportModelHtmlWriterScenarioTest.java b/jgiven-tests/src/test/java/com/tngtech/jgiven/report/html/ReportModelHtmlWriterScenarioTest.java deleted file mode 100644 index f249840eb8..0000000000 --- a/jgiven-tests/src/test/java/com/tngtech/jgiven/report/html/ReportModelHtmlWriterScenarioTest.java +++ /dev/null @@ -1,195 +0,0 @@ -package com.tngtech.jgiven.report.html; - -import static java.util.Arrays.asList; - -import java.io.IOException; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import com.tngtech.java.junit.dataprovider.DataProvider; -import com.tngtech.java.junit.dataprovider.DataProviderRunner; -import com.tngtech.java.junit.dataprovider.UseDataProvider; -import com.tngtech.jgiven.JGivenScenarioTest; -import com.tngtech.jgiven.report.model.GivenReportModel; -import com.tngtech.jgiven.report.model.StepStatus; -import com.tngtech.jgiven.tags.*; - -@FeatureHtmlReport -@RunWith( DataProviderRunner.class ) -public class ReportModelHtmlWriterScenarioTest extends JGivenScenarioTest, WhenReportModelHtmlWriter, ThenHtmlOutput> { - - @DataProvider - public static Object[][] statusTexts() { - return new Object[][] { - { StepStatus.PASSED, "something happens.*" }, - { StepStatus.FAILED, "something happens failed.*" }, - { StepStatus.SKIPPED, "something happens skipped.*" }, - { StepStatus.PENDING, - "something happens pending.*" }, - }; - } - - @Test - @UseDataProvider( "statusTexts" ) - public void step_status_appears_correctly_in_HTML_reports( StepStatus status, String expectedString ) { - given().a_report_model_with_one_scenario() - .and().step_$_is_named( 1, "something happens" ) - .and().step_$_has_status( 1, status ); - when().the_HTML_report_is_generated(); - then().the_HTML_report_contains_pattern( expectedString ); - } - - @Test - @Issue( "#9" ) - public void HTML_in_arguments_is_escaped_in_HTML_reports() { - given().a_report_model_with_one_scenario() - .and().case_$_has_a_when_step_$_with_argument( 1, "test", "" ); - when().the_HTML_report_is_generated(); - then().the_HTML_report_contains_pattern( "<someHtmlTag>" ); - } - - @Test - @FeatureDataTables - public void step_arguments_matching_case_arguments_are_replaced_by_scenario_parameter_names() { - given().a_report_model_with_one_scenario() - .and().the_scenario_has_parameters( "param1", "param2" ) - .and().the_scenario_has_$_cases( 2 ) - .and().case_$_has_arguments( 1, "a", "b" ) - .and().case_$_has_a_when_step_$_with_argument_$_and_argument_name_$( 1, "uses the first parameter", "a", "stepArg1" ) - .and().case_$_has_a_when_step_$_with_argument_$_and_argument_name_$( 1, "uses the second parameter", "b", "stepArg2" ) - .and().case_$_has_arguments( 2, "c", "d" ) - .and().case_$_has_a_when_step_$_with_argument_$_and_argument_name_$( 2, "uses the first parameter", "c", "stepArg1" ) - .and().case_$_has_a_when_step_$_with_argument_$_and_argument_name_$( 2, "uses the second parameter", "d", "stepArg2" ); - - when().the_HTML_report_is_generated(); - then().the_HTML_report_contains_pattern( "uses the first parameter.*<param1>.*second" ) - .and().the_HTML_report_contains_pattern( "uses the second parameter.*<param2>.*Cases" ) - .and().the_HTML_report_contains_a_data_table_with_header_values( "param1", "param2" ) - .and().line_$_of_the_data_table_has_arguments_$( 1, "a", "b" ) - .and().line_$_of_the_data_table_has_arguments_$( 2, "c", "d" ); - } - - @Test - @FeatureDataTables - public void scenario_parameters_and_step_arguments_can_be_mixed() { - given().a_report_model_with_one_scenario() - .and().the_scenario_has_parameters( "param1" ) - .and().the_scenario_has_$_cases( 2 ) - .and().case_$_has_arguments( 1, "a" ) - .and().case_$_has_a_when_step_$_with_argument_$_and_argument_name_$( 1, "uses the first parameter", "a", "stepArg1" ) - .and().case_$_has_a_when_step_$_with_argument_$_and_argument_name_$( 1, "uses the second parameter", "b", "stepArg2" ) - .and().case_$_has_arguments( 2, "c" ) - .and().case_$_has_a_when_step_$_with_argument_$_and_argument_name_$( 2, "uses the first parameter", "c", "stepArg1" ) - .and().case_$_has_a_when_step_$_with_argument_$_and_argument_name_$( 2, "uses the second parameter", "d", "stepArg2" ); - - when().the_HTML_report_is_generated(); - then().the_HTML_report_contains_pattern( "uses the first parameter.*<param1>.*second" ) - .and().the_HTML_report_contains_pattern( "uses the second parameter.*<stepArg2>.*Cases" ) - .and().the_HTML_report_contains_a_data_table_with_header_values( "param1", "stepArg2" ) - .and().line_$_of_the_data_table_has_arguments_$( 1, "a", "b" ) - .and().line_$_of_the_data_table_has_arguments_$( 2, "c", "d" ); - } - - @Test - @FeatureDataTables - public void derived_parameters_with_the_same_name_should_be_avoided() { - given().a_report_model_with_one_scenario() - .and().the_scenario_has_$_cases( 2 ) - .and().case_$_has_a_when_step_$_with_argument_$_and_argument_name_$( 1, "step1", "a", "stepArg" ) - .and().case_$_has_a_when_step_$_with_argument_$_and_argument_name_$( 1, "step2", "b", "stepArg" ) - .and().case_$_has_a_when_step_$_with_argument_$_and_argument_name_$( 2, "step1", "c", "stepArg" ) - .and().case_$_has_a_when_step_$_with_argument_$_and_argument_name_$( 2, "step2", "d", "stepArg" ); - - when().the_HTML_report_is_generated(); - then().the_HTML_report_contains_pattern( "step1.*<stepArg>.*step2" ) - .and().the_HTML_report_contains_pattern( "step2.*<stepArg2>.*Cases" ) - .and().the_HTML_report_contains_a_data_table_with_header_values( "stepArg", "stepArg2" ) - .and().line_$_of_the_data_table_has_arguments_$( 1, "a", "b" ) - .and().line_$_of_the_data_table_has_arguments_$( 2, "c", "d" ); - } - - @Test - @FeatureDataTables - @FeatureDerivedParameters - public void when_data_tables_are_generated_then_step_parameter_placeholders_are_correct_in_HTML_reports() { - given().a_report_model_with_one_scenario() - .and().the_scenario_has_parameters( "param1", "param2" ) - .and().the_scenario_has_$_cases( 2 ) - .and().case_$_has_arguments( 1, "x", "y" ) - .and().case_$_has_a_when_step_$_with_argument_$_and_argument_name_$( 1, "uses the first parameter", "a", "stepArg1" ) - .and().case_$_has_a_when_step_$_with_argument_$_and_argument_name_$( 1, "uses the second parameter", "b", "stepArg2" ) - .and().case_$_has_arguments( 2, "x2", "y2" ) - .and().case_$_has_a_when_step_$_with_argument_$_and_argument_name_$( 2, "uses the first parameter", "c", "stepArg1" ) - .and().case_$_has_a_when_step_$_with_argument_$_and_argument_name_$( 2, "uses the second parameter", "d", "stepArg2" ); - - when().the_HTML_report_is_generated(); - then().the_HTML_report_contains_pattern( "uses the first parameter.*<stepArg1>.*second" ) - .and().the_HTML_report_contains_pattern( "uses the second parameter.*<stepArg2>.*Cases" ) - .and().the_HTML_report_contains_a_data_table_with_header_values( "stepArg1", "stepArg2" ) - .and().line_$_of_the_data_table_has_arguments_$( 1, "a", "b" ) - .and().line_$_of_the_data_table_has_arguments_$( 2, "c", "d" ); - } - - @Test - public void when_cases_are_structurally_different_then_each_case_appears_seperately() { - given().a_report_model_with_one_scenario() - .and().the_scenario_has_$_default_cases( 2 ) - .and().the_scenario_has_parameters( "param1", "param2" ) - .and().case_$_has_arguments( 1, "arg1", "anotherArg1" ) - .and().case_$_has_a_step_$_with_argument( 1, "uses the first parameter", "arg1" ) - .and().case_$_has_arguments( 2, "arg2", "anotherArg2" ) - .and().case_$_has_a_step_$_with_argument( 2, "uses the first parameter", "arg2" ) - .and().case_$_has_step_$( 2, "some extra step method only appearing in case 2" ); - - when().the_HTML_report_is_generated(); - then().the_HTML_report_contains_pattern( "Case 1: param1 = arg1, param2 = anotherArg1" ) - .and().the_HTML_report_contains_pattern( "uses the first parameter.*arg1.*Case 2" ) - .and().the_HTML_report_contains_pattern( "Case 2: param1 = arg2, param2 = anotherArg2" ) - .and().the_HTML_report_contains_pattern( "uses the first parameter.*arg2.*" ) - .and().the_HTML_report_contains_pattern( "some extra step method only appearing in case 2" ); - } - - @Test - public void the_error_message_of_failed_scenarios_are_reported() { - given().a_report_model_with_one_scenario() - .and().the_scenario_has_$_default_cases( 1 ) - .and().case_$_fails_with_error_message( 1, "Test Error" ); - when().the_HTML_report_is_generated(); - then().the_HTML_report_contains_text( "
    Failed: Test Error
    " ); - } - - @Test - @FeatureDuration - public void the_duration_of_steps_are_reported() { - given().a_report_model_with_one_scenario() - .and().step_$_has_a_duration_of_$_nano_seconds( 1, 123456789 ); - when().the_HTML_report_is_generated(); - then().the_HTML_report_contains_text( "(123.46 ms)" ); - } - - @Test - @FeatureDuration - public void the_duration_of_scenarios_are_reported() { - given().a_report_model_with_one_scenario() - .and().the_scenario_has_a_duration_of_$_nano_seconds( 123456789 ); - when().the_HTML_report_is_generated(); - then().the_HTML_report_contains_text( "(123.46 ms)" ); - } - - @Test - @FeatureTableStepArguments - public void the_static_HTML_report_generator_handles_data_table_arguments() throws IOException { - given().a_report_model() - .and().a_step_has_a_data_table_with_following_values( asList( - asList( "header1", "header2" ), - asList( "value1", "value2" ), - asList( "value3", "value4" ) ) ); - when().the_HTML_report_is_generated(); - then().the_HTML_report_contains_pattern( ".*\n" + - ".*.*.*.*\n" + - ".*.*.*.*\n" + - ".*.*.*.*\n" + - "
    .*header1.*.*header2.*
    .*value1.*.*value2.*
    .*value3.*.*value4.*
    " ); - } -} diff --git a/jgiven-tests/src/test/java/com/tngtech/jgiven/report/html/StaticHtmlReportGeneratorTest.java b/jgiven-tests/src/test/java/com/tngtech/jgiven/report/html/StaticHtmlReportGeneratorTest.java deleted file mode 100644 index 92d0a5c9ca..0000000000 --- a/jgiven-tests/src/test/java/com/tngtech/jgiven/report/html/StaticHtmlReportGeneratorTest.java +++ /dev/null @@ -1,101 +0,0 @@ -package com.tngtech.jgiven.report.html; - -import java.io.IOException; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import com.tngtech.java.junit.dataprovider.DataProvider; -import com.tngtech.java.junit.dataprovider.DataProviderRunner; -import com.tngtech.jgiven.JGivenScenarioTest; -import com.tngtech.jgiven.report.WhenReportGenerator; -import com.tngtech.jgiven.report.json.GivenJsonReports; -import com.tngtech.jgiven.report.model.StepStatus; -import com.tngtech.jgiven.tags.FeatureHtmlReport; -import com.tngtech.jgiven.tags.FeatureTags; -import com.tngtech.jgiven.tags.Issue; - -@RunWith( DataProviderRunner.class ) -@FeatureHtmlReport -public class StaticHtmlReportGeneratorTest extends - JGivenScenarioTest, WhenReportGenerator, ThenStaticHtmlReportGenerator> { - - @Test - @DataProvider( { "0", "1", "3" } ) - public void the_static_HTML_reporter_generates_one_file_for_each_test_class( int n ) throws IOException { - given().$_report_models( n ) - .and().the_reports_exist_as_JSON_files(); - - when().the_static_HTML_reporter_is_executed(); - - then().an_index_file_exists() - .and().an_HTML_file_exists_for_each_test_class(); - } - - @Test - @FeatureTags - public void the_static_HTML_reporter_generates_one_file_for_each_tag() throws IOException { - given().a_report_model() - .and().the_first_scenario_has_tag( "TestTag" ) - .and().the_report_exist_as_JSON_file(); - - when().the_static_HTML_reporter_is_executed(); - - then().a_file_with_name_$_exists( "TestTag.html" ); - } - - @Test - @FeatureTags - public void the_static_HTML_reporter_generates_one_file_for_each_tag_value() throws IOException { - given().a_report_model() - .and().the_report_has_$_scenarios( 2 ) - .and().scenario_$_has_tag_$_with_value_$( 1, "TestTag", "123" ) - .and().scenario_$_has_tag_$_with_value_$( 2, "TestTag", "456" ) - .and().the_report_exist_as_JSON_file(); - - when().the_static_HTML_reporter_is_executed(); - - then().a_file_with_name_$_exists( "TestTag-123.html" ) - .and().a_file_with_name_$_exists( "TestTag-456.html" ); - } - - @Test - @Issue( "#29" ) - public void the_static_HTML_report_generates_one_file_for_all_failed_scenarios() throws IOException { - given().a_report_model() - .and().the_report_has_$_scenarios( 1 ) - .and().case_$_of_scenario_$_has_failed( 1, 1 ) - .and().the_report_exist_as_JSON_file(); - when().the_static_HTML_reporter_is_executed(); - then().a_file_with_name_$_exists( "failed.html" ); - } - - @Test - @Issue( "#33" ) - public void the_failed_file_generated_by_the_static_HTML_report_generator_contains_scenarios_where_some_cases_are_failed() - throws IOException { - given().a_report_model() - .and().the_report_has_$_scenarios( 1 ) - .and().the_scenario_has_$_default_cases( 2 ) - .and().case_$_of_scenario_$_has_failed( 1, 1 ) - .and().step_$_of_case_$_has_status( 1, 1, StepStatus.FAILED ) - .and().the_report_exist_as_JSON_file(); - when().the_static_HTML_reporter_is_executed(); - then().a_file_with_name_$_exists( "failed.html" ) - .and().file_$_contains_scenario_$( "failed.html", 1 ); - } - - @Test - @Issue( "#33" ) - public void the_failed_file_generated_by_the_static_HTML_report_generator_contains_failed_scenarios_where_all_steps_are_successful() - throws IOException { - given().a_report_model() - .and().the_report_has_$_scenarios( 1 ) - .and().case_$_of_scenario_$_has_failed( 1, 1 ) - .and().the_report_exist_as_JSON_file(); - when().the_static_HTML_reporter_is_executed(); - then().a_file_with_name_$_exists( "failed.html" ) - .and().file_$_contains_scenario_$( "failed.html", 1 ); - } - -} diff --git a/jgiven-tests/src/test/java/com/tngtech/jgiven/report/html/ThenHtmlOutput.java b/jgiven-tests/src/test/java/com/tngtech/jgiven/report/html/ThenHtmlOutput.java deleted file mode 100644 index 4e108a44af..0000000000 --- a/jgiven-tests/src/test/java/com/tngtech/jgiven/report/html/ThenHtmlOutput.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.tngtech.jgiven.report.html; - -import java.util.Arrays; -import java.util.List; -import java.util.regex.Pattern; - -import org.assertj.core.api.Assertions; - -import com.tngtech.jgiven.Stage; -import com.tngtech.jgiven.annotation.ExpectedScenarioState; -import com.tngtech.jgiven.report.model.ReportModel; -import com.tngtech.jgiven.report.model.ScenarioCaseModel; - -public class ThenHtmlOutput extends Stage { - @ExpectedScenarioState - ReportModel reportModel; - - @ExpectedScenarioState - String html; - - public ThenHtmlOutput the_HTML_report_contains_a_data_table_with_header_values( String... headerValues ) { - StringBuilder patternBuilder = new StringBuilder(); - patternBuilder.append( ".*\\s*.*" ); - patternBuilder.append( "\\s*\\s*" ); - for( String value : headerValues ) { - patternBuilder.append( "\\s*\\s*" ); - } - patternBuilder.append( "\\s*\\s*" ); - patternBuilder.append( "\\s*.*
    #" + value + "Status
    .*" ); - return the_HTML_report_contains_pattern( patternBuilder.toString() ); - } - - public ThenHtmlOutput line_$_of_the_data_table_has_arguments_$( int line, String... args ) { - StringBuilder patternBuilder = new StringBuilder(); - patternBuilder.append( ".*.*" ); - patternBuilder.append( getPatternForTableLine( line, Arrays.asList( args ) ) ); - patternBuilder.append( "\\s*
    .*" ); - return the_HTML_report_contains_pattern( patternBuilder.toString() ); - } - - public ThenHtmlOutput the_data_table_has_one_line_for_the_arguments_of_each_case() { - StringBuilder patternBuilder = new StringBuilder(); - patternBuilder.append( ".*.*" ); - for( ScenarioCaseModel caseModel : reportModel.getLastScenarioModel().getScenarioCases() ) { - patternBuilder.append( getPatternForTableLine(caseModel.getCaseNr(), caseModel.getExplicitArguments() ) ); - } - patternBuilder.append( "\\s*
    .*" ); - return the_HTML_report_contains_pattern( patternBuilder.toString() ); - } - - private StringBuilder getPatternForTableLine( int caseNr, List explicitArguments ) { - StringBuilder patternBuilder = new StringBuilder(); - patternBuilder.append( "\\s*" ); - patternBuilder.append( "\\s*" + caseNr + "\\s*" ); - for( String arg : explicitArguments ) { - patternBuilder.append( "\\s*" + arg + "\\s*" ); - } - patternBuilder.append( "\\s*.*icon-ok.*\\s*" ); - patternBuilder.append( "\\s*" ); - return patternBuilder; - } - - public ThenHtmlOutput the_HTML_report_contains_pattern( String patternString ) { - Pattern pattern = Pattern.compile( ".*" + patternString + ".*", Pattern.MULTILINE | Pattern.DOTALL ); - Assertions.assertThat( html ).matches( pattern ); - return self(); - } - - public ThenHtmlOutput the_HTML_report_contains_text( String text ) { - Assertions.assertThat( html ).contains( text ); - return self(); - } -} diff --git a/jgiven-tests/src/test/java/com/tngtech/jgiven/report/html/ThenStaticHtmlReportGenerator.java b/jgiven-tests/src/test/java/com/tngtech/jgiven/report/html/ThenStaticHtmlReportGenerator.java deleted file mode 100644 index 92dc1b14c5..0000000000 --- a/jgiven-tests/src/test/java/com/tngtech/jgiven/report/html/ThenStaticHtmlReportGenerator.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.tngtech.jgiven.report.html; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.io.File; -import java.io.IOException; - -import com.tngtech.jgiven.annotation.ExpectedScenarioState; -import com.tngtech.jgiven.report.ThenReportGenerator; -import com.tngtech.jgiven.report.model.ReportModel; -import com.tngtech.jgiven.report.model.ScenarioModel; - -public class ThenStaticHtmlReportGenerator> extends ThenReportGenerator { - - @ExpectedScenarioState - protected File customCssFile; - - public SELF an_index_file_exists() { - return a_file_with_name_$_exists( "index.html" ); - } - - public SELF an_HTML_file_exists_for_each_test_class() { - for( ReportModel model : reportModels ) { - a_file_with_name_$_exists( model.getClassName() + ".html" ); - } - return self(); - } - - public SELF the_custom_CSS_file_is_copied_to_the_target_directory() { - assertThat( new File( targetReportDir, customCssFile.getName() ) ).exists(); - return self(); - } - - public SELF file_$_contains_scenario_$( String fileName, int scenarioNr ) throws IOException { - final ScenarioModel scenarioModel = reportModels.get( 0 ).getScenarios().get( 0 ); - final String regex = ".*.*"; - return file_$_contains_pattern(fileName, regex); - } - -} diff --git a/jgiven-tests/src/test/java/com/tngtech/jgiven/report/html/WhenReportModelHtmlWriter.java b/jgiven-tests/src/test/java/com/tngtech/jgiven/report/html/WhenReportModelHtmlWriter.java deleted file mode 100644 index a0463c39a6..0000000000 --- a/jgiven-tests/src/test/java/com/tngtech/jgiven/report/html/WhenReportModelHtmlWriter.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.tngtech.jgiven.report.html; - -import com.tngtech.jgiven.Stage; -import com.tngtech.jgiven.annotation.ExpectedScenarioState; -import com.tngtech.jgiven.annotation.ProvidedScenarioState; -import com.tngtech.jgiven.report.model.ReportModel; - -public class WhenReportModelHtmlWriter extends Stage { - - @ExpectedScenarioState - protected ReportModel reportModel; - - @ProvidedScenarioState - protected String html; - - public void the_HTML_report_is_generated() { - html = ReportModelHtmlWriter.toString( reportModel ); - } - -}