Skip to content

Commit

Permalink
make it easier for users to inject custom reports
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrthomas committed Mar 26, 2021
1 parent 71f2e98 commit ade95d3
Showing 1 changed file with 26 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,49 +35,37 @@
*/
public interface SuiteReports {

Report featureReport(Suite suite, FeatureResult featureResult);
default Report featureReport(Suite suite, FeatureResult featureResult) {
return Report.template("karate-feature.html")
.reportDir(suite.reportDir)
.reportFileName(featureResult.getFeature().getPackageQualifiedName() + ".html")
.variable("results", featureResult.toKarateJson())
.build();
}

Report tagsReport(Suite suite, TagResults tagResults);
default Report tagsReport(Suite suite, TagResults tagResults) {
return Report.template("karate-tags.html")
.reportDir(suite.reportDir)
.variable("results", tagResults.toKarateJson())
.build();
}

Report timelineReport(Suite suite, TimelineResults timelineResults);
default Report timelineReport(Suite suite, TimelineResults timelineResults) {
return Report.template("karate-timeline.html")
.reportDir(suite.reportDir)
.variable("results", timelineResults.toKarateJson())
.build();
}

Report summaryReport(Suite suite, Results results);
default Report summaryReport(Suite suite, Results results) {
return Report.template("karate-summary.html")
.reportDir(suite.reportDir)
.variable("results", results.toKarateJson())
.build();
}

public static final SuiteReports DEFAULT = new SuiteReports() {

@Override
public Report featureReport(Suite suite, FeatureResult fr) {
return Report.template("karate-feature.html")
.reportDir(suite.reportDir)
.reportFileName(fr.getFeature().getPackageQualifiedName() + ".html")
.variable("results", fr.toKarateJson())
.build();
}

@Override
public Report tagsReport(Suite suite, TagResults tr) {
return Report.template("karate-tags.html")
.reportDir(suite.reportDir)
.variable("results", tr.toKarateJson())
.build();
}

@Override
public Report timelineReport(Suite suite, TimelineResults tr) {
return Report.template("karate-timeline.html")
.reportDir(suite.reportDir)
.variable("results", tr.toKarateJson())
.build();
}

@Override
public Report summaryReport(Suite suite, Results results) {
return Report.template("karate-summary.html")
.reportDir(suite.reportDir)
.variable("results", results.toKarateJson())
.build();
}

// defaults
};

}

0 comments on commit ade95d3

Please sign in to comment.