问题: 项目中使用spring testcontext和junit做测试工作, 使用的时候出现如下情形:org/junit/Assume$AssumptionViolatedException; nested exception is java.lang.NoClassDefFoundError: org/junit/Assume$AssumptionViolatedException
原因:Spring2.5的Sring-Test对于JUnit有个累人的要求,JUnit的版本必须是4.4,不支持高版本(如4.5、4.7等)。否则,会产生java.lang.ClassNotFoundException: org.junit.Assume$AssumptionViolatedException异常。
spring的官方jira:https://jira.springsource.org/browse/SPR-5145
解决方式:
(1)你用的是Spring2.5,则必须换成junit-4.4.jar.依赖修改为:
- <dependency>
- <groupId>com.alibaba.external</groupId>
- <artifactId>test.junit</artifactId>
- <version>4.4</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.alibaba.external</groupId>
- <artifactId>sourceforge.spring.test</artifactId>
- <version>2.5.6</version>
- <scope>test</scope>
- </dependency>
(2)将Spring升级至Spring3
参考:http://teddywang.iteye.com/blog/652215
http://thorndike.iteye.com/blog/263197
转载于:https://blog.51cto.com/tianya23/582483