您好,登錄后才能下訂單哦!
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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。