我在两个不同的测试步骤中添加了Assertion。 每个断言都给了我节点数。
例如: -
Assertion 1:- Give count of nodes from JDBC test step
Assertion 2:- Give count of nodes from JSON response test step
我如何比较这两个断言?
答案 0 :(得分:0)
可以使用包含断言的groovy script
来完成。如果我理解正确,你可以将测试重新设计成一个案例,这样就不会依赖其他测试,即每个测试都应该是独立的。
假设案例 - 具有以下步骤的测试案例
以下是第3步中的sudo代码:
jdbcNodeCount
。jsonNodeCount
。如何在groovy步骤中获得其他步骤的响应?你走了:
//You may rename step1, step2 as needed to your environment
//initializing count variables
def jdbcNodeCount = 0
def jsonNodeCount = 0
//Get step1 response
def jdbcResponse = context.expand('${step1#Response}')
log.info jdbcResponse
//process jdbcResponse and assign jdbcNodeCount, add needed steps
//also add additional the assertions required for jdbcResponse here, so that you would not need Assertion 1 that you had already
//Similarly get step2 response
def jsonResponse = context.expand('${step2#Response}')
log.info jsonResponse
//process jsonResponse and assign jsonNodeCount, add needed steps
//also add additional the assertions required for jsonResponse here, so that you would not need Assertion 2 that you had already
//compare now
assert jsonNodeCount == jdbcNodeCount, "Node counts are not matching"