Spring Framework
  1. Spring Framework
  2. SPR-5145

Spring TestContext Framework not compatible with JUnit 4.5

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.5.5
    • Fix Version/s: 3.0 M3
    • Component/s: Test
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      After upgrading to junit 4.5 my test class which uses the SpringJUnit4ClassRunner gets a NoClassDefFoundError:

      org.apache.maven.surefire.booter.SurefireExecutionException: org/junit/Assume$AssumptionViolatedException; nested exception is java.lang.NoClassDefFoundError: org/junit/Assume$AssumptionViolatedException
      java.lang.NoClassDefFoundError: org/junit/Assume$AssumptionViolatedException
      at org.springframework.test.context.junit4.SpringMethodRoadie.runTestMethod(SpringMethodRoadie.java:240)
      at org.springframework.test.context.junit4.SpringMethodRoadie$RunBeforesThenTestThenAfters.run(SpringMethodRoadie.java:333)
      at org.springframework.test.context.junit4.SpringMethodRoadie.runWithRepetitions(SpringMethodRoadie.java:217)
      at org.springframework.test.context.junit4.SpringMethodRoadie.runTest(SpringMethodRoadie.java:197)
      at org.springframework.test.context.junit4.SpringMethodRoadie.run(SpringMethodRoadie.java:143)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invokeTestMethod(SpringJUnit4ClassRunner.java:142)
      at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:59)

      etc.

      This is a Junit 4.5 issue. The static class AssumptionViolatedException within org.junit.Assume that existed in 4.4 has become org.junit.internal.AssumptionViolatedException.

      The file tiger/mock/org/springframework/test/context/junit4/SpringMethodRoadie.java imports org.junit.Assume.AssumptionViolatedException which is why my test is failing.

      Workaround is to stick with Junit 4.4.

      (Aside: are there plans to create a "SpringTEST" component?).

        Issue Links

          Activity

          Hide
          Juergen Hoeller added a comment -

          Werner, Spring 3.0 GA is now scheduled for Monday Dec 14 (i.e. in four days); it is literally around the corner. Also, using last week's 3.0 RC3 for the time being is going to ensure a smooth upgrade path to GA, since we are sorting out very specific bugs only at this point. So 3.0 RC3 is a fine release and very recommendable for development purposes already; I just wouldn't go to production with it yet.

          With respect to using a brand-new JUnit version with older versions of Spring: Fundamentally, there is no reason to keep holding on to Spring 2.5 when upgrading other parts of your stack. Take JUnit, or Tiles, or JRuby - all of which we support in new versions now in Spring 3.0 that did not work with Spring 2.5. All of those libs require Java 5 anyway, so the Java 5+ requirement in Spring 3 shouldn't be a showstopper for anyone here.

          We are trying to be forward compatible as far possible but well, if JUnit breaks its runner contract from 4.4 to 4.5 and Spring 2.5 only had JUnit 4.4 to work against at the time, there is not much we can do other than catch up with the latest JUnit release in the latest generation of Spring. In particular sine Spring 2.5 has to remain compatible with JUnit 4.4 for support reasons: i.e . for people who stick with their original stack from back in 2007...

          In summary, please give Spring 3.0 RC3 a try and let us know whether its JUnit 4.7 support works for your purposes

          Juergen

          Show
          Juergen Hoeller added a comment - Werner, Spring 3.0 GA is now scheduled for Monday Dec 14 (i.e. in four days); it is literally around the corner. Also, using last week's 3.0 RC3 for the time being is going to ensure a smooth upgrade path to GA, since we are sorting out very specific bugs only at this point. So 3.0 RC3 is a fine release and very recommendable for development purposes already; I just wouldn't go to production with it yet. With respect to using a brand-new JUnit version with older versions of Spring: Fundamentally, there is no reason to keep holding on to Spring 2.5 when upgrading other parts of your stack. Take JUnit, or Tiles, or JRuby - all of which we support in new versions now in Spring 3.0 that did not work with Spring 2.5. All of those libs require Java 5 anyway, so the Java 5+ requirement in Spring 3 shouldn't be a showstopper for anyone here. We are trying to be forward compatible as far possible but well, if JUnit breaks its runner contract from 4.4 to 4.5 and Spring 2.5 only had JUnit 4.4 to work against at the time, there is not much we can do other than catch up with the latest JUnit release in the latest generation of Spring. In particular sine Spring 2.5 has to remain compatible with JUnit 4.4 for support reasons: i.e . for people who stick with their original stack from back in 2007... In summary, please give Spring 3.0 RC3 a try and let us know whether its JUnit 4.7 support works for your purposes Juergen
          Hide
          Werner Guttmann added a comment -

          Thanks, Jürgen, for letting me know about the immediate release date for 3.0. This should ease our pain substantially.

          And we will definitely give things a try re: JUnit 4.7, etc.

          Show
          Werner Guttmann added a comment - Thanks, Jürgen, for letting me know about the immediate release date for 3.0. This should ease our pain substantially. And we will definitely give things a try re: JUnit 4.7, etc.
          Hide
          Dennis Kieselhorst added a comment -

          3.0 GA isn't released yet, is it?

          Show
          Dennis Kieselhorst added a comment - 3.0 GA isn't released yet, is it?
          Hide
          Sam Brannen added a comment -

          Dennis, 3.0 GA is tentatively scheduled to be released... today!

          Show
          Sam Brannen added a comment - Dennis, 3.0 GA is tentatively scheduled to be released... today!
          Hide
          Neeme Praks added a comment -

          How about creating a separate artifact for the 2.5 branch with Junit 4.5+ support?
          That would mean that existing users will not be affected and other users who need Junit 4.5+ can declare a different dependency (e.g. org.springframework:spring-test-junit45 or something along those lines).

          Probably you won't take that route anymore, but still, it's an idea, at least for the future.

          Show
          Neeme Praks added a comment - How about creating a separate artifact for the 2.5 branch with Junit 4.5+ support? That would mean that existing users will not be affected and other users who need Junit 4.5+ can declare a different dependency (e.g. org.springframework:spring-test-junit45 or something along those lines). Probably you won't take that route anymore, but still, it's an idea, at least for the future.

            People

            • Assignee:
              Sam Brannen
              Reporter:
              Alison Rosewarne
              Last updater:
              Trevor Marshall
            • Votes:
              3 Vote for this issue
              Watchers:
              11 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                4 years, 7 weeks, 3 days ago