如何忽略 SoapUI JSONPath 表达式中的动态值,而仅针对其余完整负载进行验证?

问题描述 投票:0回答:1

我想验证除 Dynamics 时间戳之外的所有键值对的 JSON 响应。我要么必须编写多个 JSONPath 表达式断言,要么可以在一个断言中实现这一目标?

只想忽略时间戳值匹配,其余的都应该匹配。

json soapui json-path-expression
1个回答
0
投票

使用脚本断言来验证响应中的必填字段。

// Read response
def response=messageExchange.response.responseContent
 // Parse json Response
def jsonSul=new JsonSlurper().parseText(response)

def actualEnvironment = jsonSul.environment
def actualMessage = jsonSul.message
// add all required fields

def expectedEnvironment = "qa" // You can read from Properties file as well depends where you are storing the expected results.

// Validate
assert expected==actual
© www.soinside.com 2019 - 2024. All rights reserved.