`
jie66989
  • 浏览: 251179 次
  • 性别: Icon_minigender_1
  • 来自: 西安
社区版块
存档分类
最新评论

junit4应用以及和spring的整合

阅读更多
junit3
就加载junit3对应的jar包就可以
测试类需要继承junit.framework.TestCase
重写setup方法在setup加载需要的配置文件
测试方法需要以test开头testMyCase()


junit4
依赖的jar:org.hamcrest.core.jar  junit4.jar
只需要测试方法加org.junit.Test注解
或者按照3的规范继承junit.framework.TestCase并规范命名测试方法即可



和spring的整合
参考:http://blog.csdn.net/mumuzhu2011/article/details/7704120
依赖org.springframework.test.jar包

@org.junit.runner.RunWith(SpringJUnit4ClassRunner.class)
@org.springframework.test.context.ContextConfiguration
(locations = "classpath:applicationContext.xml")
public class ConsumerTest extends org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests
{
        @Resource
IConsumerDAO consumerDAOImpl;

//@Test
public void testAbc() {
System.out.println(consumerDAOImpl.getConsumer(1).getUserName());

}
}
手动加载spring配置文件 http://jie66989.iteye.com/blog/1699622

原文地址:http://jie66989.iteye.com/blog/1699640
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics