问题
Karate: I would like to assert to match parts of response
I am getting the following response: 12:10:33.960 [print] Kyc Status changed from NotStarted to Accepted.Reason: Output Address AddressLine : 6927 14TH AVE
But I would like to only make assertion to match part of the response. e.g.: "Kyc Status changed from NotStarted to Accepted."
回答1:
The following examples should solve your problem:
Scenario: Matching text
* def yourResponse = "12:10:33.960 [print] Kyc Status changed from NotStarted to Accepted.Reason: Output Address AddressLine : 6927 14TH AVE"
* match yourResponse contains "NotStarted to Accepted"
* match yourResponse !contains "does not contain"
* assert new RegExp("NotStarted to Accepted").test(yourResponse)
Needless to say, that you can use any regex with the assert new RegExp
construct.
来源:https://stackoverflow.com/questions/58504956/karate-i-would-like-to-assert-to-match-parts-of-response