我具有空手道功能,并且操作很长。在运行这些测试之前,我需要手动设置一些测试数据,这实际上是一个sql查询。有没有一种方法可以让我们在空手道中的“后台”运行此查询? 我正在尝试将状态不是“ ready_to_test”的所有值更新为“ ready_to_test”。
说我的查询是
更新my_table
设置状态=“ ready_to_test”
状态为!='ready_to_test';
编辑: 我正在尝试按以下方式运行更新查询
* def config = {username: 'postgres', password: 'postgres', url: 'jdbc:postgresql://localhost:5432/postgres', driverClassName: 'org.postgresql.Driver'}
* def DbUtil = Java.type('com.utils.DbUtils')
* def db = new DbUtil(config)
* def correctStatus = 'ready_to_test'
* def testData = db.cleanRows('UPDATE MY_TABLE M SET M.STATUS = ' 'WHERE M.STATUS != ' + correctStatus)
也尝试过 * def testData = db.cleanRows('UPDATE MY_TABLE SET STATUS ='ready_to_test'WHERE STATUS!='ready_to_test)
答案 0 :(得分:1)
请查看callSingle
API是否满足您的需求。
https://github.com/intuit/karate#karate-callsingle
var result = karate.callSingle('classpath:common.feature', { some: 'config' });