【项目实战】使用Spring Test+Junit4整合进行测试
来源:互联网 发布:linux 查看主机arp 编辑:程序博客网 时间:2024/04/26 22:47
1、使用Spring Test+Junit4整合进行测试,在此过程中导入相关Jar包以及相关SpringMVC配置文件就不在啰嗦了,这里主要看测试代码:
package com.kmcb.junit.jdbc;import com.alibaba.fastjson.JSON;import com.kmcb.blog.model.CnShare;import com.kmcb.blog.service.INoteShareService;import com.kmcb.junit.test.ApplicationContextUtil;import org.junit.Test;import org.junit.runner.RunWith;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.test.context.ContextConfiguration;import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;import java.util.List;@RunWith(SpringJUnit4ClassRunner.class)@ContextConfiguration(locations = {"classpath:spring-database.xml", "classpath:spring-mvc.xml", "classpath:spring-context.xml","classpath:spring-transaction.xml"})public class TestSpringDao extends ApplicationContextUtil { @Autowired private INoteShareService noteShareService; @Test public void springDaoTest(){ List<CnShare> shareList = noteShareService.getSelectShareAll(); for(CnShare share : shareList){ System.out.println("----"+share.toString()); } System.out.println("-----------------------------------------------"); String jsonArray = JSON.toJSONString(shareList); System.out.println("list转出Json:"+jsonArray); }}说明:重点在于@RunWith、@ContextConfiguration这两个注解。
0 0
- 【项目实战】使用Spring Test+Junit4整合进行测试
- Spring项目使用JUnit4进行测试
- Spring Test 整合JUnit4
- Spring Test整合JUnit4的使用
- spring Test 整合Junit4 使用总结
- Spring整合Junit4测试
- Spring整合JUnit4测试
- maven中使用spring的test包结合junit4进行测试。
- 使用Spring+Junit4.4进行测试
- 使用Spring+Junit4.4进行测试
- 使用Spring+Junit4.4进行测试
- Spring整合Junit4进行单元测试
- Spring整合Junit4进行单元测试
- Spring 整合Junit4进行单元测试
- Spring整合Junit4进行单元测试
- spring整合Junit4进行单元测试
- Spring整合JUnit4测试使用注解引入多个配置文件
- 使用JUnit4测试Spring
- 经典fork炸弹
- 编译原理-逆波兰表达式JAVA算法
- Hello ,Mirgo!
- jQuery 获取屏幕高度、宽度
- 基于S3C2440的USB摄像头应用简单实现之应用层框架(一)
- 【项目实战】使用Spring Test+Junit4整合进行测试
- 从苏宁电器到卡巴斯基(后传)第03篇:我与鱼C论坛的是是非非
- ASN.NET连接Access数据库开发
- 使用 install.packages() 安装所需的包
- 重载
- centos7.0时间修改
- JavaWeb模拟键盘
- Scala基础
- postgresql 关于geo 按距离排序返回 性能测试