`
dogasshole
  • 浏览: 843388 次
文章分类
社区版块
存档分类
最新评论

报错:@RunWith(SpringJUnit4ClassRunner.class) gives error

 
阅读更多

I have a JUnit 4 test class in Eclipse Ganymede that has the following annotations :

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:/applicationContext.xml"})
public class TestSybaseDao extends TestCase {

This annotation gives compilation error "Type mismatch: cannot convert from Class<SpringJUnit4ClassRunner> to Class<? extends Runner>

在写单元测试的时候,明明包导进去了但是鼠标放到调用类还会出现这个错误。

出现这种情况一般有2个原因:

1.可能刚加进去的包为加载到,需要到重构配置窗口中重新加载下所有包,一般eclipse自带的是junit4.4版本的。

2.第二种原因是spring不支持junit4.5一下的版本。所以只需要把junit4.4或者更低版本升级到更高就ok了。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics