问题: 项目中使用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.依赖修改为:

 
  
  1. <dependency> 
  2.             <groupId>com.alibaba.external</groupId> 
  3.             <artifactId>test.junit</artifactId> 
  4.             <version>4.4</version> 
  5.             <scope>test</scope> 
  6.         </dependency> 
  7.     <dependency> 
  8.             <groupId>com.alibaba.external</groupId> 
  9.             <artifactId>sourceforge.spring.test</artifactId> 
  10.             <version>2.5.6</version> 
  11.             <scope>test</scope> 
  12.         </dependency> 


(2)将Spring升级至Spring3

参考:http://teddywang.iteye.com/blog/652215

http://thorndike.iteye.com/blog/263197