The normal behaviour of 'match' in karate is that if the match fails, the scenario fails. But what if I just want to evaluate the match and get a boolean result?
Something like: *def success = (match response == expected);
A reason for this could be as follows: The 'shape' of the response could vary depending on supplied parameters, e.g. to a soap call. Example: If you ask for a person given some 'key' parameter, the result might be <result>Not found</result>
or it could be a more complex xml tree with the person record (first name, last name, age, address, city ,...).
In some cases you may want a test scenario to succeed in both cases, regardless of the different 'shapes' of the result. However, you can not use two separate matches, because at least one of them will fail. If I could just 'or' the results, the problem would be solved:
* match response == shape1 || match response == shape2
or with variables:
* def result1 = (match response == shape1)
* def result2 = (match response == shape2)
* def result3 = (match response == shape3)
* match (result1 || result2 || !shape3);
# test succeeds or boolean expression evaluates to true
Is such a thing even remotely possible in Karate, to combine the power of (boolean) expressions with several matches?
Aucun commentaire:
Enregistrer un commentaire