Results 1 to 10 of 10

Thread: spring-test breaks in Junit 4.5

  1. #1
    Join Date
    Nov 2004
    Posts
    20

    Default spring-test breaks in Junit 4.5

    Basically, Junit 4.5 took out exceptions out the constructor classes. So I am running spring2.5.5 under it will get:

    java.lang.NoClassDefFoundError: org/junit/Assume$AssumptionViolatedException at org.springframework.test.context.junit4.SpringMeth odRoadie.runTestMethod(SpringMethodRoad
    ie.java:240)
    Thanks,

    jfd

  2. #2
    Join Date
    Sep 2004
    Location
    London
    Posts
    311

    Default

    hello,
    found similar problems but looked like my test assertions was incorrect
    could you please post :
    - your code
    - your test cocde
    - your pom.xml if you are using Maven to build your project


    i dont know your whole situation.. could you run your tests using JUnit 4.4 and see results?
    i found some posts somewhere that Spring sources were compiled using JUnit4.4 and JUnit guys changed signatures of certain methods

    regards
    marco

  3. #3
    Join Date
    Apr 2006
    Posts
    19

    Default

    The spring folks built there SpringJUnit4ClassRunner to extend an internal class. The internal class changed in junit 4.5. They need to be extending BlockJUnit4ClassRunner.

  4. #4
    Join Date
    Aug 2008
    Posts
    6

    Default

    see: htxp://thorndike.javaeye.com/blog/263197
    (sorry can't post URLs yet, change "htxp to http")

    what i took from this is to bump my junit support down to 4.4. although it appears that maybe upgrading to Spring 2.5.6 will alleviate this problem.

    Thanks for leading along the right track, Adamal!

  5. #5
    Join Date
    Oct 2008
    Location
    Delhi, India
    Posts
    163

    Default

    I'm not sure if this is related but in the following code

    Code:
    @RunWith(SpringJUnit4ClassRunner.class)
    public class GenericRequestControllerTests {
    
    	@Test
    	public void testLogout() {
    		.....
    	}
    }
    I get the exception
    Code:
    java.lang.NoSuchMethodError: org.junit.runner.notification.RunNotifier.testAborted(Lorg/junit/runner/Description;Ljava/lang/Throwable;)V
    	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invokeTestMethod(SpringJUnit4ClassRunner.java:137)
    	at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:59)
    	at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:52)
    	at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:34)
    	at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:44)
    	at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:50)
    	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
    	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

  6. #6

    Default Spring 2.5.6 & JUnit 4.4 works

    I was getting the same error with Spring 2.5.6 and Junit 4.5.
    When I downgraded to JUnit 4.4, the exception went away.

  7. #7
    Join Date
    Mar 2008
    Location
    Wayzata, MN
    Posts
    15

    Default

    Thanks for the tip - I was seeing this error and downgraded to junit 4.4 which fixed it too.

  8. #8
    Join Date
    Sep 2004
    Posts
    602

    Default

    Quote Originally Posted by jfd View Post
    Basically, Junit 4.5 took out exceptions out the constructor classes. So I am running spring2.5.5 under it will get:

    java.lang.NoClassDefFoundError: org/junit/Assume$AssumptionViolatedException at org.springframework.test.context.junit4.SpringMeth odRoadie.runTestMethod(SpringMethodRoad
    ie.java:240)
    See http://jira.springframework.org/browse/SPR-5145

  9. #9
    Join Date
    Jan 2006
    Location
    Zürich, Switzerland
    Posts
    423

    Default

    Hi guys,

    FYI: as of Spring 3.0 M3, the Spring TestContext Framework is now based on JUnit 4.5.

    - Sam

  10. #10
    Join Date
    Oct 2012
    Posts
    1

    Default

    One easy way to resolve the problem is to provide the missing class. You can do that by adding the following dependency to your pom.xml file :
    <dependency>
    <groupId>com.google.code.protoj</groupId>
    <artifactId>protoj-nodep</artifactId>
    <version>1.8.4</version>
    <scope>test</scope>
    </dependency>


    So now you can keep taking advantage from the newest Junit version without having to downgrade to version 4.4.
    Youssef Hbali.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •