DFfit+JTester+TestNG数据库操作测试示例(原创)
上一篇 / 下一篇 2011-03-21 17:49:57 / 个人分类:敏捷测试
---jtester.properties---51Testing软件测试网(j8mtw1G{C;S
database.type=mysql
JzQ2d_t)H'M5^0database.url=jdbc:mysql://localhost/creditcard?characterEncoding=UTF8
~LwD,Vt~0database.userName=root51Testing软件测试网Ztl]7Bd2V*z
database.password=hjq51Testing软件测试网&G O/[,y3s
database.schemaNames=creditcard51Testing软件测试网#W,p)f9zX{Z%nU*P/K
database.driverClassName=com.mysql.jdbc.Driver
VFx7G.~0
tP6s ct0---creditcard.when.wiki---51Testing软件测试网z+QYsX~%Vda
数据库连接,使用jtester.properties中配置好的属性51Testing软件测试网 pOe5P$V|3w"O
|connect|51Testing软件测试网 l0dCjL Xq
6k,jN-t{$})K0清空creditcard表51Testing软件测试网s D7}$kOG
|clean table|creditcard|51Testing软件测试网h#G Lz'r0gt#f
5k/gh~^u;e0准备数据,往creditcard中插入2条测试使用的记录51Testing软件测试网k X ]x7O*_
|insert|creditcard|51Testing软件测试网ywI$o? g5Z
|cardnumber|banknumber|amount|username|
*ZR-e'|"f0|123456|987654321|500|qing|
k.Sz0o2B:Q0|123456|987654321|500|huang|51Testing软件测试网5j^.uQ E$H
51Testing软件测试网u_~s!?@.ID sB
51Testing软件测试网QgV!T(F Qv3oKX
提交数据51Testing软件测试网.xfCwP` m$_&}
|commit|
.x*ur/e_8D2A)R051Testing软件测试网|Z+E+T,g*p.T"w.v:n
---creditcard.then.wiki--51Testing软件测试网2q&}#`5Oz$C)Hn
|connect|51Testing软件测试网(o U^yA1fy
51Testing软件测试网P k;f |z-}(N)vR9v
根据条件查询记录,验证相应的字段
dc @Y\0{QXy0|query|select username from creditcard|
PP;jhJQf0|username|51Testing软件测试网7`h`%p2p5Q
|qing|
7I3[2RH7Hu.j0|huang|51Testing软件测试网v;Z`b:Gdi6rw[2\B
|junqinghuang|51Testing软件测试网,]Gy4ER r:gr$vS
R1TK6g K*t`0----测试代码---
+]%N m]g7P#WxJyM4r0package creditcard.repay.mapper;
9SR ~ X8h'K051Testing软件测试网5fL3J8Iz+R z#U@M8[
import mockit.Mock;
M2@2Y`2[7u @8U!E051Testing软件测试网Bs L.~,][V&X;a
import org.testng.annotations.Test;51Testing软件测试网 e4fj#wCsjRxa
51Testing软件测试网.Gb$y$L,X*c%H~"H2v
import java.io.IOException;
iYKwG,vF0import java.sql.SQLException;51Testing软件测试网hl9q(\AruH9q!u`
J k'W9EV*ra8E0import org.apache.ibatis.session.SqlSession;51Testing软件测试网uh O'j:N[;| q+r4Eve
import org.apache.ibatis.session.SqlSessionFactory;51Testing软件测试网B4GKvYp%`
import org.jtester.testng.JTester;
O3b Q |\4a0import org.jtester.unitils.dbfit.DbFit;
0m0ZN P~ {)f#L051Testing软件测试网W9Bs4T2S~'^j9y$i,x
import creditcard.repay.bean.Creditcard;51Testing软件测试网8X+m v{(Y%J.f A1F
import creditcard.repay.util.MyBatisUtil;
S(Edat Le.]Ghj8F'o0
database.type=mysql
JzQ2d_t)H'M5^0database.url=jdbc:mysql://localhost/creditcard?characterEncoding=UTF8
~LwD,Vt~0database.userName=root51Testing软件测试网Ztl]7Bd2V*z
database.password=hjq51Testing软件测试网&G O/[,y3s
database.schemaNames=creditcard51Testing软件测试网#W,p)f9zX{Z%nU*P/K
database.driverClassName=com.mysql.jdbc.Driver
VFx7G.~0
tP6s ct0---creditcard.when.wiki---51Testing软件测试网z+QYsX~%Vda
数据库连接,使用jtester.properties中配置好的属性51Testing软件测试网 pOe5P$V|3w"O
|connect|51Testing软件测试网 l0dCjL Xq
6k,jN-t{$})K0清空creditcard表51Testing软件测试网s D7}$kOG
|clean table|creditcard|51Testing软件测试网h#G Lz'r0gt#f
5k/gh~^u;e0准备数据,往creditcard中插入2条测试使用的记录51Testing软件测试网k X ]x7O*_
|insert|creditcard|51Testing软件测试网ywI$o? g5Z
|cardnumber|banknumber|amount|username|
*ZR-e'|"f0|123456|987654321|500|qing|
k.Sz0o2B:Q0|123456|987654321|500|huang|51Testing软件测试网5j^.uQ E$H
51Testing软件测试网u_~s!?@.ID sB
51Testing软件测试网QgV!T(F Qv3oKX
提交数据51Testing软件测试网.xfCwP` m$_&}
|commit|
.x*ur/e_8D2A)R051Testing软件测试网|Z+E+T,g*p.T"w.v:n
---creditcard.then.wiki--51Testing软件测试网2q&}#`5Oz$C)Hn
|connect|51Testing软件测试网(o U^yA1fy
51Testing软件测试网P k;f |z-}(N)vR9v
根据条件查询记录,验证相应的字段
dc @Y\0{QXy0|query|select username from creditcard|
PP;jhJQf0|username|51Testing软件测试网7`h`%p2p5Q
|qing|
7I3[2RH7Hu.j0|huang|51Testing软件测试网v;Z`b:Gdi6rw[2\B
|junqinghuang|51Testing软件测试网,]Gy4ER r:gr$vS
R1TK6g K*t`0----测试代码---
+]%N m]g7P#WxJyM4r0package creditcard.repay.mapper;
9SR ~ X8h'K051Testing软件测试网5fL3J8Iz+R z#U@M8[
import mockit.Mock;
M2@2Y`2[7u @8U!E051Testing软件测试网Bs L.~,][V&X;a
import org.testng.annotations.Test;51Testing软件测试网 e4fj#wCsjRxa
51Testing软件测试网.Gb$y$L,X*c%H~"H2v
import java.io.IOException;
iYKwG,vF0import java.sql.SQLException;51Testing软件测试网hl9q(\AruH9q!u`
J k'W9EV*ra8E0import org.apache.ibatis.session.SqlSession;51Testing软件测试网uh O'j:N[;| q+r4Eve
import org.apache.ibatis.session.SqlSessionFactory;51Testing软件测试网B4GKvYp%`
import org.jtester.testng.JTester;
O3b Q |\4a0import org.jtester.unitils.dbfit.DbFit;
0m0ZN P~ {)f#L051Testing软件测试网W9Bs4T2S~'^j9y$i,x
import creditcard.repay.bean.Creditcard;51Testing软件测试网8X+m v{(Y%J.f A1F
import creditcard.repay.util.MyBatisUtil;
S(Edat Le.]Ghj8F'o0