您好,登录后才能下订单哦!
1, 写入值(30,31),更新到数据表的多条记录。
sqlStr ="select column_id from 1dcq_shop_column2 where shop_id = '"+ db_Shop_id + "'"
def dbSettings=[]
def db_sub_column_id =""
sqlResult = sql.eachRow(sqlStr)
{
dbSettings << it.toRowResult()
}
for (i=0;i< dbSettings.size;i++)
{
db_sub_column_id = db_sub_column_id.toString() + dbSettings[i].column_id.toString()
if (i < dbSettings.size-1)
{
db_sub_column_id=db_sub_column_id+","
}
}
assert subColumnId == db_sub_column_id
2,初始化数据
import groovy.sql.Sql
//import groovyx.net.http.ContentType
log.info("-------------------------------------------------The Test Step start ---------------------------------------------")
/*
* 1,获取数据库连接参数,连接数据库
*/
def tpProperties = testRunner.testCase.getProject()
def tsProperties = testRunner.testCase.getTestSuite()
def tcProperties = testRunner.getTestCase()
def service_ip= tpProperties.getPropertyValue( "YDGJ_IP" )
def refreshPath = tpProperties.getPropertyValue( "refreshPath" )
def db_url = tpProperties.getPropertyValue( "DB_Connection_URL" )
def db_user = tpProperties.getPropertyValue( "DB_loginname" )
def db_pwd = tpProperties.getPropertyValue( "DB_Password" )
def db_driver = tpProperties.getPropertyValue( "DB_Driver_Class" )
def sql = Sql.newInstance(db_url,db_user,db_pwd,db_driver)
log.info("------ 1,获取数据库连接参数,连接数据库 finished")
/*
* 2,初始化数据库表
*/
// begin 初始化数据
def sqlStr = "call sp_easydata_genAll()"
log.info("自动生成业务数据 : " + sqlStr)
sql.execute(sqlStr)
log.info("------ 2,初始化表基础数据 finished")
/*
* 3,设置补充用例所需表数据
*/
/*
def sqlStr = "select first 1 from "
log.info(sqlStr)
sql.execute(sqlStr);
*/
log.info("------ 3,设置补充用例所需表数据 finished, (请根据业务设置!)")
/*
* 4,设置 或 从数据表获取 用例参数值
*/
//设置数据-必填
def curTime = System.currentTimeMillis()
//log.info("curTime:" + curTime)
def shopName= "shopName"+curTime
log.info(shopName)
tcProperties.setPropertyValue( "shopName", shopName)
tcProperties.setPropertyValue( "userId", "2916011")
tcProperties.setPropertyValue( "shopkeeper","店主姓名呀")
tcProperties.setPropertyValue( "provinceId","360000")
3, 通过设置变量,获取变量完成值传递
def tpProperties = testRunner.testCase.getProject()
def tsProperties = testRunner.testCase.getTestSuite()
def tcProperties = testRunner.getTestCase()
def shopName = tcProperties.getPropertyValue("shopName" )
def userId = tcProperties.getPropertyValue("userId" )
def shopkeeper = tcProperties.getPropertyValue("shopkeeper" )
def provinceId = tcProperties.getPropertyValue("provinceId" )
三,string 用split 处理成数组
log.info("skillsCertificateNos: " + skillsCertificateNos)
String[] strAry = skillsCertificateNos.split(",");
log.info ("strAry.size():" + strAry.size())
for (i=0;i<strAry.size();i++)
{
sqlStr = "select count(*) as cnt from 1dcq_p_w_upload where file_no = '"+ strAry[i] + "'"
log.info(sqlStr)
sqlResult = sql.firstRow(sqlStr)
log.info ("skillsCertificateNos,,,,,,,,sqlResult.cnt : " + sqlResult.cnt)
assert sqlResult.cnt == 1
}
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。