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

Spring TestContext Framework not compatible with JUnit 4.5

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: 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?).

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                sbrannen Sam Brannen
                Reporter:
                alisonr 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:
                  8 years, 21 weeks, 5 days ago