空手道API,2个不同的响应匹配

时间:2018-11-30 11:14:28

标签: api cucumber karate

我有以下情况,并且我希望第一个或第二个响应匹配(* def首先或* def第二个)。两者都可以。以下不适用于我。你能帮忙吗?

场景:A

Given path 'api/..../0.1/..../availability'
* def futureDate = Java.type('uk.co.vw.api.StringUtil').getFutureDate()
* def first = {"available":'#boolean',"collection":'#boolean',"date":#(futureDate),"lift":'#boolean',"bookingAvailability":'#array',"times":'#array',"loan":'#boolean',"delivery":'#boolean' }
* def second = {"code": "#string","message": "#string"}
  And params {dealerNumber: '00111', date: #(futureDate), serviceCodes: 'MIN:1.4,OER:0.85', mot: 0, postcode: "W2", waitingjob: 0 }
When method get
Then status 200
  And match response contains any (first, second)

1 个答案:

答案 0 :(得分:1)

有两个潜在的解决方法。

date的值设置为变量futureDate。您的写作#(futureDate)应该是这样的'#(futureDate)'

您可以以此为断言

And match response[*] contains (second)
   And match response[*] contains (first)