JBehave
  1. JBehave
  2. JBEHAVE-1054

Regression: configuration method inherited from JUnitStories class not being overridden

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Not A Bug
    • Affects Version/s: 3.9.2
    • Fix Version/s: 3.10
    • Component/s: Core
    • Labels:
      None
    • Number of attachments :
      4

      Description

      When creating a JUnitStories class, the overridden configuration method is no longer executed starting in JBehave 3.9.2.

      I also tested this with 3.9.3, 3.9.5 and 4.0-beta-11 and the issue persists. Only by changing the dependency version in my POM back to 3.9.1 does the method override correctly again.

      I have attached my StoryReporter class, the abstract class where the issue presents when version >= 3.9.2 and an example Embeddable JUnitRunner class that inherits from it.

      MyStoryReporter.class is simply a Reporter that prints information to System.out where every callback prints a line starting with [JBEHAVE] and emits whatever information is available:

      You can run any story file from resources and see that the StoryReporter does not get used unless you are on a version prior to 3.9.2. You can also add a breakpoint in configuration and see that the breakpoint will be hit in 3.9.1 but is never hit in 3.9.2 and later.

      1. BaseJBehaveValidator.java
        2 kB
        Paul Sernatinger
      2. ExampleJBehaveValidator.java
        1 kB
        Paul Sernatinger
      3. MyStoryReporter.java
        4 kB
        Paul Sernatinger
      4. pom.patch
        0.8 kB
        Mauro Talevi

        Activity

        Hide
        Mauro Talevi added a comment - - edited

        Yes, this is a side effect of JBEHAVE-1009. The ConfigurableEmbedder now uses the configuration() method lazily only if there is no other configuration set.

        To override with your instance of Configuration, you can use the #useConfiguration() method in the constructor of the class inheriting from JUnitStories.

        The CoreStories in the core examples show how to configure using the configuration() method.

        If you still have problems, please provide a fully working example buildable and executable by command-line (either a zip or a git repo) so we can reproduce your behaviour.

        Show
        Mauro Talevi added a comment - - edited Yes, this is a side effect of JBEHAVE-1009 . The ConfigurableEmbedder now uses the configuration() method lazily only if there is no other configuration set. To override with your instance of Configuration, you can use the #useConfiguration() method in the constructor of the class inheriting from JUnitStories. The CoreStories in the core examples show how to configure using the configuration() method. If you still have problems, please provide a fully working example buildable and executable by command-line (either a zip or a git repo) so we can reproduce your behaviour.
        Hide
        Paul Sernatinger added a comment -

        I tried the guidance you gave, and added the following to my class:

        BaseJBehaveValidator()

        { useConfiguration(configuration()); }

        However, it still does not work as expected, and additionally now fails to build on the command line with the following:

        java.lang.NoSuchMethodError: org.jbehave.core.reporters.StoryReporterBuilder.withReporters([Lorg/jbehave/core/reporters/StoryReporter;)Lorg/jbehave/core/reporters/StoryReporterBuilder;

        I have created a git repository to help with identifying this issue:

        https://github.com/oscillot/configuration-example/

        You should find two branches:

        working - version is set to 3.9.1 and new Constructor is left commented out
        notworking - version is set to 3.9.2 in POM and Constructor has been added per your previous guidance.

        Please let me know if I can provide anything additional, we would very much like to move to at least 3.9.3 to get the conditional Lifecycle features added.

        Show
        Paul Sernatinger added a comment - I tried the guidance you gave, and added the following to my class: BaseJBehaveValidator() { useConfiguration(configuration()); } However, it still does not work as expected, and additionally now fails to build on the command line with the following: java.lang.NoSuchMethodError: org.jbehave.core.reporters.StoryReporterBuilder.withReporters([Lorg/jbehave/core/reporters/StoryReporter;)Lorg/jbehave/core/reporters/StoryReporterBuilder; I have created a git repository to help with identifying this issue: https://github.com/oscillot/configuration-example/ You should find two branches: working - version is set to 3.9.1 and new Constructor is left commented out notworking - version is set to 3.9.2 in POM and Constructor has been added per your previous guidance. Please let me know if I can provide anything additional, we would very much like to move to at least 3.9.3 to get the conditional Lifecycle features added.
        Hide
        Mauro Talevi added a comment -

        You're using an inconsistent mix of version for the jbehave dependencies in your pom.xml.

        With the attached patch (i.e. using the same jbehave version for all dependencies) it picks up your configuration.

        Show
        Mauro Talevi added a comment - You're using an inconsistent mix of version for the jbehave dependencies in your pom.xml. With the attached patch (i.e. using the same jbehave version for all dependencies) it picks up your configuration.
        Mauro Talevi made changes -
        Field Original Value New Value
        Attachment pom.patch [ 66683 ]
        Hide
        Mauro Talevi added a comment -

        Incidentally, you seem to be using both the annotated embedder and extending JUnitStories (which extends the configurable embedder). Using the two is redundant and may lead to inconsistent behaviour.

        It should suffice to use one of the two.

        Show
        Mauro Talevi added a comment - Incidentally, you seem to be using both the annotated embedder and extending JUnitStories (which extends the configurable embedder). Using the two is redundant and may lead to inconsistent behaviour. It should suffice to use one of the two.
        Hide
        Paul Sernatinger added a comment -

        Attached patch resolves my issues when run from the command line.

        Show
        Paul Sernatinger added a comment - Attached patch resolves my issues when run from the command line.
        Paul Sernatinger made changes -
        Resolution Not A Bug [ 6 ]
        Fix Version/s 3.9.2 [ 20180 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Mauro Talevi made changes -
        Fix Version/s 3.9.2 [ 20180 ]
        Fix Version/s 3.9.6 [ 20672 ]

          People

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

            Dates

            • Created:
              Updated:
              Resolved: