在 SoapUI 的 groovy 脚本中显示发送的请求

Show sent request in groovy script in SoapIU

我尝试在 SoapUI 中创建集成测试:

  1. 属性 文件中有 属性 myId=1234
  2. 我发送 soap 请求(名为 myRequest)包含 <messageId>${myId}</messageId>
  3. 此请求有效,因为 ${myId} 已替换为 1234。我收到响应。
  4. 在我的 groovy 脚本中,我想显示已发送的请求,<messageId> 的值:
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context);
def request = groovyUtils.getXmlHolder("myRequest#Request");

log.info(request["//messageId"]);

输出:${myId}

预期输出:1234

你有什么想法吗?

通过对同一请求步骤使用 Script Assertion,无需使用额外的 Groovy Script 测试步骤即可实现此目的。

在下方使用 Script Assertion 显示请求以及正在替换的值或发送到服务器的实际请求。

//Check if you have got the response
assert context.response, "Response is null or empty"

//show the actual request is being sent
log.info context.rawRequest