Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-5292

Add support for parameterized JUnit 4 tests in the Spring TestContext Framework

    Details

    • Last commented by a User:
      false

      Description

      SpringJUnit4ClassRunner is unaware of @Parameters annotation that normally is processed with JUnit's own Parameterized runner.

      1. ConstructorArgFromSpringConfigTestRunner.java
        4 kB
        Ruud Senden
      2. junit4_SpringParameterizedRunner.java
        6 kB
        Manjuka Soysa
      3. ParameterizedDirtiesContext.java
        5 kB
        Nikolay Blindov
      4. SpringJUnit4ParameterizedClassRunner.java
        22 kB
        Josef Eisl
      5. SpringJUnit4ParameterizedClassRunner.java.v2
        3 kB
        Ib
      6. SpringParameterizedRunner.java
        5 kB
        Jon Burgin

        Issue Links

          Activity

          Hide
          rsenden Ruud Senden added a comment -

          Run test once for each Spring bean that matches the single test constructor parameter type.

          Show
          rsenden Ruud Senden added a comment - Run test once for each Spring bean that matches the single test constructor parameter type.
          Hide
          nikolayb Nikolay Blindov added a comment -

          I have attached junit runner (a file namedParameterizedDirtiesContext.java) worked for me. My ruuner is inheritor of junit Parameterized ruuner and uses inheritor of SpringJUnit4ClassRunner for creation a test. So, the runner uses junit approach for parameterizing a unit test and support all SpringJUnit functionalites. The ruuner work with junit 4.8.2 and or higher version.

          Show
          nikolayb Nikolay Blindov added a comment - I have attached junit runner (a file namedParameterizedDirtiesContext.java) worked for me. My ruuner is inheritor of junit Parameterized ruuner and uses inheritor of SpringJUnit4ClassRunner for creation a test. So, the runner uses junit approach for parameterizing a unit test and support all SpringJUnit functionalites. The ruuner work with junit 4.8.2 and or higher version.
          Hide
          mbjelac Marko Bjelac added a comment -

          I tried several runners attached here, but confirm that only SpringJUnit4ParameterizedClassRunner.java.v2 works for me.

          Show
          mbjelac Marko Bjelac added a comment - I tried several runners attached here, but confirm that only SpringJUnit4ParameterizedClassRunner.java.v2 works for me.
          Hide
          koen_serry Koen Serry added a comment -

          Since a pull request is created (and is confirmed to work), is there any reason not to merge it?

          Show
          koen_serry Koen Serry added a comment - Since a pull request is created (and is confirmed to work), is there any reason not to merge it?
          Hide
          sbrannen Sam Brannen added a comment -

          I am resolving this issue as essentially a duplicate of SPR-7731, since SPR-7731 introduced support for integrating the Spring TestContext Framework into JUnit via Rules instead of a Runner.

          In other words, thanks to the support for rules introduced in SPR-7731, there is no longer a need for a custom extension of SpringJUnit4ClassRunner that supports parameterized tests... since you can now simply use JUnit's Parameterized runner with Spring's rules.

          See ParameterizedSpringRuleTests for a concrete example.

          Show
          sbrannen Sam Brannen added a comment - I am resolving this issue as essentially a duplicate of SPR-7731 , since SPR-7731 introduced support for integrating the Spring TestContext Framework into JUnit via Rules instead of a Runner . In other words, thanks to the support for rules introduced in SPR-7731 , there is no longer a need for a custom extension of SpringJUnit4ClassRunner that supports parameterized tests... since you can now simply use JUnit's Parameterized runner with Spring's rules. See ParameterizedSpringRuleTests for a concrete example.

            People

            • Assignee:
              sbrannen Sam Brannen
              Reporter:
              tuomas_kiviaho Tuomas Kiviaho
              Last updater:
              Sam Brannen
            • Votes:
              42 Vote for this issue
              Watchers:
              46 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                5 weeks, 3 days ago