JBehave
  1. JBehave
  2. JBEHAVE-541

Meta tags (and other things) injectable into components

    Details

    • Number of attachments :
      0

      Description

      Meta tags can be injected into step methods. They can't be injected into step-pojo constructors, nor in any capacity to components that are themselves injectable into step-pojo constructors.

      Workaround people have to do: accept the meta-tag into the step-pojo's step method and hand it to wherever needs.

      In our particular case, Page objects are being made by a DI container, and it would be better separation of concerns to have meta tags injected where they are needed, and not in the steps class (which only passes them on).

      The senior developer in question wishes, in lieu of something better, that StoryRunner.RunContext.Meta was statically available (on a thread local) and that page objects could pull it when they need it. That's a breach of IoC of course, but you get why he wishes for it.

        Activity

        Hide
        Mauro Talevi added a comment -

        What are the usecases you are trying to address?

        What one may do is to define an interface MetaEnabled that steps classes can optionally implement and the current Meta can be passed on to the instance (ah the good ol' Avalon days are coming back).

        You can't have any parsed data (including Meta) injected into the constructors of the steps classes without doing very complicated back flipping and throwing IoC out the window.

        Show
        Mauro Talevi added a comment - What are the usecases you are trying to address? What one may do is to define an interface MetaEnabled that steps classes can optionally implement and the current Meta can be passed on to the instance (ah the good ol' Avalon days are coming back). You can't have any parsed data (including Meta) injected into the constructors of the steps classes without doing very complicated back flipping and throwing IoC out the window.
        Hide
        Marius Brot added a comment -

        I can describe our scenario a bit and why we would appreciate any method to get meta information for a story wide context.

        We have a dispose stack, which disposes everything what was created during the story, afterwards.
        Example: If a database was created by a step of the current story, this database will be removed by the dispose stack, after the story has finished.

        But for debugging purposes we would need any mechanism to disable the dispose stack on story level.
        Example: If we know there is something going wrong on a specific story, we want to disable the dispose stack and go in deep with an developer.

        As story based mechanism we would see meta tags as a perfect solution. Since adding a simple @skipDisposal could be sufficient to disable the dispose stack.

        Show
        Marius Brot added a comment - I can describe our scenario a bit and why we would appreciate any method to get meta information for a story wide context. We have a dispose stack, which disposes everything what was created during the story, afterwards. Example: If a database was created by a step of the current story, this database will be removed by the dispose stack, after the story has finished. But for debugging purposes we would need any mechanism to disable the dispose stack on story level. Example: If we know there is something going wrong on a specific story, we want to disable the dispose stack and go in deep with an developer. As story based mechanism we would see meta tags as a perfect solution. Since adding a simple @skipDisposal could be sufficient to disable the dispose stack.

          People

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

            Dates

            • Created:
              Updated: