SOAPUI:- 比较不同测试用例的两个断言

SOAPUI:- Comparing two assertions of different test cases

我在两个不同的测试步骤中添加了断言。 每个断言都给我节点数。

例如:-

Assertion 1:- Give count of nodes from JDBC test step
Assertion 2:- Give count of nodes from JSON response test step

我如何比较这两个断言?

可以使用 groovy script 包括断言来完成。如果我理解正确,您可以将测试重新设计为单个案例,这样就不会对其他测试有任何依赖性,即每个测试都应该是独立的。

假设案例 - 具有以下步骤的测试案例

  1. step1 - 类型为 Jdbc 测试步骤
  2. step2 - 类型为 Rest Test Step
  3. step3 - 类型为 Groovy 脚本测试步骤

这是第 3 步中的 sudo 代码:

  • 获取第 1 步的响应并对该响应执行您想执行的任何处理。既然你提到了节点数,就把节点数放在一个变量中,比如 jdbcNodeCount.
  • 类似地,对 step2 做同样的事情,并将节点计数放在另一个变量中,比如 jsonNodeCount
  • 可以很容易地比较这两个变量。

如何从groovy步中的with获取其他步的响应?给你:

//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"