diff --git a/src/main/java/net/masterthought/cucumber/ReportBuilder.java b/src/main/java/net/masterthought/cucumber/ReportBuilder.java index 543da5d0b..ee616df5c 100755 --- a/src/main/java/net/masterthought/cucumber/ReportBuilder.java +++ b/src/main/java/net/masterthought/cucumber/ReportBuilder.java @@ -53,8 +53,7 @@ public class ReportBuilder { private static final ObjectMapper mapper = new ObjectMapper(); private ReportResult reportResult; - private final ReportParser reportParser; - + private ReportParser reportParser; private Configuration configuration; private List jsonFiles; @@ -71,6 +70,14 @@ public ReportBuilder(List jsonFiles, Configuration configuration) { reportParser = new ReportParser(configuration); } + public ReportParser getReportParser() { + return reportParser; + } + + public void setReportParser(ReportParser reportParser) { + this.reportParser = reportParser; + } + /** * Parses provided files and generates the report. When generating process fails * report with information about error is provided. diff --git a/src/test/java/net/masterthought/cucumber/ReportBuilderTest.java b/src/test/java/net/masterthought/cucumber/ReportBuilderTest.java index 1fff9618b..e060d3595 100644 --- a/src/test/java/net/masterthought/cucumber/ReportBuilderTest.java +++ b/src/test/java/net/masterthought/cucumber/ReportBuilderTest.java @@ -62,6 +62,23 @@ void ReportBuilder_storesFilesAndConfiguration() { assertThat(assignedConfiguration).isSameAs(configuration); } + @Test + void ReportBuilder_setsAndGetsCustomReportParser(){ + // given + final List jsonFiles = new ArrayList<>(); + final Configuration configuration = new Configuration(null, null); + final ReportParser reportParser = new ReportParser(configuration); + + // when + ReportBuilder builder = new ReportBuilder(jsonFiles, configuration); + builder.setReportParser(reportParser); + + // then + ReportParser assignedReportParser = Whitebox.getInternalState(builder, "reportParser"); + + assertThat(assignedReportParser).isSameAs(builder.getReportParser()); + } + @Test void generateReports_GeneratesPages() {