【发布时间】:2019-04-29 16:32:38
【问题描述】:
我是 groovy 脚本和肥皂 UI 的新手。我在测试步骤中添加了脚本断言。当我运行测试用例时,脚本断言没有运行。我必须手动运行它以验证我的响应是否正确。 有人可以帮我吗? 我的 groovy 脚本测试断言:
import groovy.json.JsonSlurper
//grab response
def response = messageExchange.response.responseContent
//Convert to JsonSluper to access data
def list = new JsonSlurper().parseText(response)
//check delegates are in one session per timeslot
for (i = 0; i < list.size(); i++) {
// find all items for this delegate in this timeslot
def itemsForThisDelegateInThisTimeslot = list.findAll {element -> element.delegateId == list[i].delegateId && element.agendaItemId== list[i].agendaItemId}
log.info(list[i].delegateId)
// there should not be more than 1
if(itemsForThisDelegateInThisTimeslot.size() > 1) {
log.info(list[i].delegateId + "Delegate already assigned to a workshop at same time");
//Assert fail in execution
throw new Error ('Fail')
}
}
【问题讨论】: