JBehave
  1. JBehave
  2. JBEHAVE-549

StoryReporter forces me to write non thread safe code

    Details

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

      Description

      The StoryBuilder interface includes the following methods

      void beforeStory(Story story, boolean givenStory);
      void beforeScenario(String scenarioTitle);
      void beforeExamples(List<String> steps, ExamplesTable table);

      Which forces me to store the story and scenario in local variables in order to know exactly which examples are about to be run in my beforeExamples method. This results in a slightly ugly but definately not thread safe StoryBuilder implementation. It also forces me to implement beforeStory() and beforeScenario() when I was actually only interested in beforeExamples()

      If the methods were:
      void beforeStory(Story story, boolean givenStory);
      void beforeScenario(Story story, boolean givenStory, String scenarioTitle);
      void beforeExamples(Story story, boolean givenStory, String scenarioTitle, List<String> steps, ExamplesTable table);

      I would not need to keep track of the current state and my implementation could be Thread safe (and prettier).

        Activity

        Hide
        Lance added a comment -

        I forgot to mention that I only referenced 3 methods as an example. Most methods in the interface will need the extra parameter(s) added.

        Show
        Lance added a comment - I forgot to mention that I only referenced 3 methods as an example. Most methods in the interface will need the extra parameter(s) added.
        Hide
        Lance added a comment -

        This zip file attached to JBEHAVE-551 (jbehave-improved-junit-runner.zip) has a workaround for this issue. It contains a new interface StoryReporter2 and an adapter StoryReporter2Adapter which adapts a StoryReporter to a StoryReporter2 to in a thread safe way.

        Show
        Lance added a comment - This zip file attached to JBEHAVE-551 (jbehave-improved-junit-runner.zip) has a workaround for this issue. It contains a new interface StoryReporter2 and an adapter StoryReporter2Adapter which adapts a StoryReporter to a StoryReporter2 to in a thread safe way.

          People

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

            Dates

            • Created:
              Updated: