JBehave
  1. JBehave
  2. JBEHAVE-871

StepsBehaviour test broken for OpenJDK 7

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 3.7.4
    • Fix Version/s: 3.7.5, 3.8
    • Component/s: Core
    • Labels:
      None
    • Environment:
    • Number of attachments :
      1

      Description

      Unit test StepsBehaviour.shouldReportFailuresInBeforeAndAfterMethods is broken when run on JDK 7 (see stacktrace attached). With JDK 6 this error doesn't occur.

      What actually breaks the test is that methods annotated with @BeforeScenario are picked in different order for the two JDK versions. This is caused by the fact that java.lang.Class.getMethods() returns methods in no particular order as clearly stated in its javadoc and probably its implementation has been changed.

      The question is whether it's enough just to fix the test to enforce the order or this issue affects the framework more deeply and additional measures are needed.

        Activity

        Hide
        Alexander Lehmann added a comment -

        I think I had a similar problem in another test class that assumed a specific order for the list of methods where I changed the unit test to look at all members of the array.

        I think it would be correct just to fix the test as well, since there are no assumptions made on the order of methods when you actually run your methods (or there shouldn't be at least).

        Show
        Alexander Lehmann added a comment - I think I had a similar problem in another test class that assumed a specific order for the list of methods where I changed the unit test to look at all members of the array. I think it would be correct just to fix the test as well, since there are no assumptions made on the order of methods when you actually run your methods (or there shouldn't be at least).
        Hide
        Mauro Talevi added a comment -

        Can't reproduce it on Mac - Java version: 1.7.0_09, vendor: Oracle Corporation

        Yes, the root of the issue is the order in which the Class.getMethods() returns the methods.

        If you could provide a patch to fix the test on OpenJDK, it'd be appreciated.

        Show
        Mauro Talevi added a comment - Can't reproduce it on Mac - Java version: 1.7.0_09, vendor: Oracle Corporation Yes, the root of the issue is the order in which the Class.getMethods() returns the methods. If you could provide a patch to fix the test on OpenJDK, it'd be appreciated.
        Hide
        Volodymyr Sobotovych added a comment -

        Sure, I'll provide the patch once I get used to github and provide a link here as decribed in this article: http://jbehave.org/reference/preview/how-to-contribute.html

        Show
        Volodymyr Sobotovych added a comment - Sure, I'll provide the patch once I get used to github and provide a link here as decribed in this article: http://jbehave.org/reference/preview/how-to-contribute.html
        Hide
        Volodymyr Sobotovych added a comment - - edited

        I've pushed the fix to my fork. Please review and let me know if you have any questions: https://github.com/wheleph/jbehave-core/commit/29a132272809c7d641477a6a81f483f7477cd6e0

        Also created a pull request on github with those changes

        Show
        Volodymyr Sobotovych added a comment - - edited I've pushed the fix to my fork. Please review and let me know if you have any questions: https://github.com/wheleph/jbehave-core/commit/29a132272809c7d641477a6a81f483f7477cd6e0 Also created a pull request on github with those changes
        Hide
        Mauro Talevi added a comment -

        Pulled with thanks.

        Show
        Mauro Talevi added a comment - Pulled with thanks.
        Mauro Talevi made changes -
        Field Original Value New Value
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 3.7.5 [ 18997 ]
        Resolution Fixed [ 1 ]
        Mauro Talevi made changes -
        Summary StepsBehaviour.shouldReportFailuresInBeforeAndAfterMethods broken for OpenJDK 7 StepsBehaviour test broken for OpenJDK 7
        Mauro Talevi made changes -
        Fix Version/s 3.8 [ 19104 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Volodymyr Sobotovych
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: