Karate: I would like to assert to match parts of response

我是研究僧i 提交于 2020-01-04 05:07:33

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!