标签:blog class code java get int
如下图:选择了子数据,默认选中父级数据,数据库中会存储两条数据
为使脚本通用性更好,不写死两级,可将数据放到List里处理,代码如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 |
String companyName = null ; companyName = "测试公司1.1" ; stepInfo( "校验数据" ); DBUtils db = new
DBUtils(); boolean
flag = true ; List<String> companyIdList = new
ArrayList<String>(); String getComId = null ; String companyId = null ; String parentId = null ; String getParentName = null ; while (flag){ getComId = "select * from global_company where c_companyname=‘"
+ companyName + "‘" ; companyId = db.getStringList(getComId, "c_companyid" ).get( 0 ); //获取当前公司的ID, companyIdList.add(companyId); //并将其放到list里 parentId = db.getStringList(getComId, "c_parentid" ).get( 0 ); //获取当前公司的父ID if (parentId == null ){ //如果父级不存在,则置flag为false使循环结束 flag = false ; } else
{ getParentName = "select * from global_company where c_companyid=‘"
+ parentId + "‘" ; //若父级存在,则根据父ID查询出父级name companyName = db.getStringList(getParentName, "c_companyname" ).get( 0 ); continue ; } } String sql = null ; for ( int
i = 0 ; i < companyIdList.size(); i ++){ sql = "select * from shop_goods_stock where c_infoid=‘"
+ infoId + "‘ and c_companyid=‘"
+ companyIdList.get(i) + "‘" ; assertEquals(db.getStringList(sql, "c_stockid" ).size(), 1 , "按公司和商品名称查出的数据不为1.这个公司为:"
+ companyIdList.get(i)); String actualNum = db.getStringList(sql, "i_stocknum" ).get( 0 ); String actualNow = db.getStringList(sql, "c_issell" ).get( 0 ); assertEquals(actualNum,quantity, "上架数量检查不正确" ); assertEquals(actualNow,isNow, "是否现在上架检查不正确" ); } |
注:校验的时候,依次校验
选择子数据,默认存储父数据 的校验方法,布布扣,bubuko.com
标签:blog class code java get int
原文地址:http://www.cnblogs.com/joewu/p/3712044.html