JBehave
  1. JBehave
  2. JBEHAVE-637

Eliminate Format as a factory for StoryReporter

    Details

    • Type: Improvement Improvement
    • Status: Open Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: 3.x
    • Component/s: Core
    • Labels:
      None
    • Number of attachments :
      0

      Description

      StoryReporter is made by Format, and that feels an unnecessary OO separation. Making custom reporters is cumbersome as a result. Can we kill the Format class?

        Activity

        Hide
        Mauro Talevi added a comment -

        Not following the line of thought. Format allows to easily define different formats and reporters.

        What would replace it?

        Show
        Mauro Talevi added a comment - Not following the line of thought. Format allows to easily define different formats and reporters. What would replace it?
        Hide
        Paul Hammant added a comment -

        I would 'new up' reporters where I need them.

        However I could be misunderstanding the nature of the linkage between the two. In a given a given run, for say "Console Output" how many times will createStoryReporter(..) be called? Once per story? or Once per run?

        I assume it is the latter, as the console remains constant for the duration of the run. With the latter a single instance of ConsoleOutput spanning multiple stories (say in parallel) could detangle the output so that it makes sense in the shared output. Without that "whole run" view of the essential visitation of the methods, a whole run style of reporting will not be possible.

        Show
        Paul Hammant added a comment - I would 'new up' reporters where I need them. However I could be misunderstanding the nature of the linkage between the two. In a given a given run, for say "Console Output" how many times will createStoryReporter(..) be called? Once per story? or Once per run? I assume it is the latter, as the console remains constant for the duration of the run. With the latter a single instance of ConsoleOutput spanning multiple stories (say in parallel) could detangle the output so that it makes sense in the shared output. Without that "whole run" view of the essential visitation of the methods, a whole run style of reporting will not be possible.
        Hide
        Mauro Talevi added a comment -

        The main usecase for the Format is to abstract the interaction with the StoryReporterBuilder, which creates the FilePrintStreamFactory and hands it over to the Format.createStoryReporter() method. It also makes it much simpler to define reporters in the configuration.

        The StoryReporterBuilder.build(path) method is invoked once per story (via the Configuration.storyReporter(path)) in the StoryRunner.

        I'm struggling to see how the Format may feel an unncessary separation. IMO, Format.HTML or new Format("HTML") is simpler than

        public static final Format HTML = new Format("HTML") {
        
                @Override
                public StoryReporter createStoryReporter(FilePrintStreamFactory factory,
                        StoryReporterBuilder storyReporterBuilder) {
                    factory.useConfiguration(storyReporterBuilder.fileConfiguration("html"));
                    return new HtmlOutput(factory.createPrintStream(), storyReporterBuilder.keywords()).doReportFailureTrace(
                            storyReporterBuilder.reportFailureTrace()).doCompressFailureTrace(
                            storyReporterBuilder.compressFailureTrace());
                }
            };
        
        
        Show
        Mauro Talevi added a comment - The main usecase for the Format is to abstract the interaction with the StoryReporterBuilder, which creates the FilePrintStreamFactory and hands it over to the Format.createStoryReporter() method. It also makes it much simpler to define reporters in the configuration. The StoryReporterBuilder.build(path) method is invoked once per story (via the Configuration.storyReporter(path)) in the StoryRunner. I'm struggling to see how the Format may feel an unncessary separation. IMO, Format.HTML or new Format("HTML") is simpler than public static final Format HTML = new Format( "HTML" ) { @Override public StoryReporter createStoryReporter(FilePrintStreamFactory factory, StoryReporterBuilder storyReporterBuilder) { factory.useConfiguration(storyReporterBuilder.fileConfiguration( "html" )); return new HtmlOutput(factory.createPrintStream(), storyReporterBuilder.keywords()).doReportFailureTrace( storyReporterBuilder.reportFailureTrace()).doCompressFailureTrace( storyReporterBuilder.compressFailureTrace()); } };

          People

          • Assignee:
            Unassigned
            Reporter:
            Paul Hammant
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: