JBehave
  1. JBehave
  2. JBEHAVE-1047

Support for @Given/@When/@Then annotations in interfaces

    Details

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

      Description

      Right now, this kind of step is not supported.

      public interface FooBarSteps {
         @Given("whatever bla bla")
         void givenWhateverBlaBla();
      
      }
      
      public class FooBarStepsImpl {
          @Override
          public void givenWhateverBlaBla() {
          }
      }
      

      The FooBarStepsImpl won't be detected as annotation-bearing class.

      However, I think it'd be great to support them. It would allow JDK Proxies for steps, and would allow separating step interface construction from actual step implementation.

      One example use-case would be making it possible to test, with the same stories, two "client libraries" with the same functionality but different APIs, by reimplementing the step classes using each library's API.

      I think the StepsFactory-related changes needed are simple (just take into account also interfaces when exploring methods for annotations), and I've identified also some changes needed in the Steps class. An ongoing, tentative and untested attempt for the required changes in the Steps class is here:
      https://github.com/flozano/jbehave-core/commit/1d7d002f16e7e786797b2240c535bfc0d13d97e0

      Any opinion about this?

        Activity

        Francisco Lozano made changes -
        Field Original Value New Value
        Description Right now, this kind of step is not supported.
        {CODE}
        public interface FooBarSteps {
           @Given("whatever bla bla")
           void givenWhateverBlaBla();

        }

        public class FooBarStepsImpl {
            @Override
            public void givenWhateverBlaBla() {
            }
        }
        {CODE}

        The FooBarStepsImpl won't be detected as annotation-bearing class.

        However, I think it'd be great to support them. It would allow JDK Proxies for steps, and would allow separating step interface construction from actual step implementation.

        One example use-case would be making it possible to test, with the same stories, two "client libraries" with the same functionality but different APIs, by reimplementing the step classes using each library's API.

        I think the StepsFactory-related changes needed are simple (just take into account also interfaces when exploring methods for annotations), and I've identified also some changes needed in the Steps class. An ongoing, tentative and untested attempt for the required changes in the Steps class is here:
        https://github.com/flozano/jbehave-core/commit/1d7d002f16e7e786797b2240c535bfc0d13d97e0

        Any opinion about this?

          People

          • Assignee:
            Unassigned
            Reporter:
            Francisco Lozano
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: