- 博客(8)
- 收藏
- 关注
原创 提取mybatis mapper接口
在使用mybatis 3.0的annotation之后,会产生大量mapper接口文件。使用下面这个类可以提取这些mapper的清单 public final class MybatisMapperScanner extends ClassPathScanningCandidateComponentProvider { { addIncludeFilter(new Annot...
2013-03-16 19:22:06
287
原创 获取类的所有子类
开发过程中,有时需要获取某个包下的所有类,或者基于指定规则获取类清单。 比较常见的解决方案是自己遍历目录,查找所有.class文件。 下面这个方法使用spring工具类实现,简化过程,不再需要自己遍历目录 /** * 获取在指定包下某个class的所有非抽象子类 * * @param parentClass * ...
2013-03-16 19:15:10
849
更有效的mock,优化spring框架下的mock方法
本文主要是提供了一种解决方案,用于解决spring管理的测试用例在mock过程中,如何有效管理mock宿主和mock实体,并优化mock方法 一、基础类 1、Sping配置基础 @ContextConfiguration(locations = { "classpath:spring.xml" }) public abstract class BaseServiceTest extends...
2011-08-06 11:59:17
521
1
使用jmock测试System.in和System.out
本文要求读者已具备juit和jmock基础 在TDD过程中需要测试代码中的System.in和System.out。 技术难点包括 1、mock宿主还原 2、inout参数的行为模拟 3、mock system.in和out 1、测试主体 @Service class ConsoleManagerBizImpl{ private static Logger LOGGE...
2011-08-06 11:39:43
333
使用mybatis3.0 annotation接口简化数据访问
数据访问进化简史,比较简单,不负责能跑起来 一、原始的sql select address from user where name='test' 二、jdbc //若干操作 String sql="select address from user where name='"+name+"'"; //执行 //解析结果 //包括若干个try catch ...
2011-07-31 00:11:16
140
使用工厂方法mock测试方法体内中new出来的对象
本文假设读者已了解mock的基本定义,基础使用场景。本文的mock框架采用jmock 1、mock经典测试场景 class ToTest { private Member m; public void test(Varible v){ m.call(); v.call(); } } 通过mock出一个m和v...
2011-07-22 10:29:48
1790
原创 另一个hosts文件
66.249.89.99 docs.google.com 66.249.89.99 spreadsheets.google.com 66.249.89.99 spreadsheets0.google.com 66.249.89.99 docs1.google.com 66.249.89.99 clients1.google.com 66.249.89.99 clients2.google...
2011-07-20 13:23:20
131
原创 不使用中间变量交换两个int值
[code="java"] int a=1; int b=2; a=a+b;//a=3,b=2 b=a-b;//a=3,b=1 a=a-b;//a=2,b=1 [/code]
2011-07-19 10:47:35
120
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅