测试管理,自动化测试、手机客户端测试、wap站点测试研究
JTester+TestNG+Jmockit示例(原创)
上一篇 /
下一篇 2011-03-18 15:45:32
/ 个人分类:敏捷测试
我们可以通过mock的方式模拟假数据,对XXX等项目进行测试,解决对环境的依赖问题,代码如下所示:51Testing软件测试网7~
GxW2Z dj
测试中使用到的工具:JTester+TestNG+Jmockit
Vyi^yWx
I.I1S051Testing软件测试网@Adt;Hh#O
publicclassICreditcardBOTestextendsJTester {51Testing软件测试网B[_N}:@
51Testing软件测试网$PB:h;};}Ou
@Test(groups ="testsample2")
#u!TO+Hz0 publicvoidtestGetOneCreditcard()throwsSQLException,
IOException {51Testing软件测试网"iQ4D%D.p2DQQ
Mockit.setUpMock(creditcard.repayment.dao.impl.CreditcardDaoImpl.class,
#{fd
{P,g` E0 newObject() {51Testing软件测试网1rE4YW
rh Hr:_
@Mock
)s0b"fnh
w}0
CreditcardgetOneCreditcard(inti){
4S_YB&s5T&s;S3b_[0
Creditcard cc =newCreditcard();
k'zS
gYJ*A
L0
cc.setAmount(400);51Testing软件测试网Y;UL
h+E"e
cc.setBanknumber("343434343234345345");51Testing软件测试网#^%N%c!G7M+EVC
returncc;51Testing软件测试网^/l&t `b2_5W
}51Testing软件测试网RJk'[_[3g)]W;]
});51Testing软件测试网,K;Bg.txU8w
51Testing软件测试网T
GW
u(P0|
CreditcardDaoImpl cdi =newCreditcardDaoImpl();51Testing软件测试网t.ESEZ
i
p
H
want.string("343434343234345345").isEqualTo(cdi.getOneCreditcard(0).getBanknumber());
"U&GCZ1uF0
}
:\%|D6t2VP.|u^0}51Testing软件测试网1L C&K6?Y$?"]-j2x
收藏
举报
TAG: