Spring Framework
  1. Spring Framework
  2. SPR-7731

Provide @Rule alternative to SpringJUnit4ClassRunner

    Details

    • Last commented by a User:
      true

      Description

      Sometimes (always?) it would be nice to have a @Rule implementation that did the job of the current test context loader and runner. The main motivation for this is to use other runners (e.g. @Parameterized, @Categories). There might even be a case for deprecating the runner in favour of a @Rule?

      1. SpringContextRule.java
        5 kB
        Neale Upstone
      2. SpringContextRule.java
        4 kB
        Neale Upstone

        Issue Links

          Activity

          Hide
          The Alchemist added a comment -

          Any updates on this?

          Show
          The Alchemist added a comment - Any updates on this?
          Hide
          Sam Brannen added a comment -

          The Alchemist, this issue is currently assigned to the 3.3 backlog and will be reassigned to a concrete release pending available resources and demand from the community.

          Regards,

          Sam

          Show
          Sam Brannen added a comment - The Alchemist , this issue is currently assigned to the 3.3 backlog and will be reassigned to a concrete release pending available resources and demand from the community. Regards, Sam
          Hide
          Sam Brannen added a comment -
          Show
          Sam Brannen added a comment - Pull request submitted by Philippe Marschall in conjunction with SPR-10217 : https://github.com/SpringSource/spring-framework/pull/222
          Hide
          Neale Upstone added a comment -

          Just noticed that I've broken links here to my github account. I changed account name from nealeoc to nealeu - edit the links and they'll work, if you need to get at them.

          Show
          Neale Upstone added a comment - Just noticed that I've broken links here to my github account. I changed account name from nealeoc to nealeu - edit the links and they'll work, if you need to get at them.
          Hide
          Vasiliy Gagin added a comment - - edited

          I'm very interested in this being implemented. I've being discussing this with JUnit guys, asking them to provide better integration points, no luck yet.
          They have some valid concerns. In general they like to support tests which are not based on Java Method. I've used Cucumber once, so i see the value. I guess that is why their current poster child TestRule gets Description as a parameter instead of FrameworkMathod as was in case of MethodRule.
          Current TestContext has a reference to java.lang.reflect.Method. It seems unnecessary to restrict Spring decorated tests to only Java method based.
          Would there be any will to change TestContext to remove reference to a Method and use something like array of Annotations or Description instead? It seems that Method is used for annotations only anyway.
          This will allow for @Rule based implementation of TestRule?

          Show
          Vasiliy Gagin added a comment - - edited I'm very interested in this being implemented. I've being discussing this with JUnit guys, asking them to provide better integration points, no luck yet. They have some valid concerns. In general they like to support tests which are not based on Java Method. I've used Cucumber once, so i see the value. I guess that is why their current poster child TestRule gets Description as a parameter instead of FrameworkMathod as was in case of MethodRule. Current TestContext has a reference to java.lang.reflect.Method. It seems unnecessary to restrict Spring decorated tests to only Java method based. Would there be any will to change TestContext to remove reference to a Method and use something like array of Annotations or Description instead? It seems that Method is used for annotations only anyway. This will allow for @Rule based implementation of TestRule?

            People

            • Assignee:
              Sam Brannen
              Reporter:
              Dave Syer
              Last updater:
              Vasiliy Gagin
            • Votes:
              17 Vote for this issue
              Watchers:
              17 Start watching this issue

              Dates

              • Created:
                Updated:
                Days since last comment:
                20 weeks, 1 day ago