Is it possible to do soft assertion in the karate

后端 未结 1 1158
伪装坚强ぢ
伪装坚强ぢ 2020-11-30 14:52

Is it possible to continue the execution of test step even if one of the assert/match fails?

Ex:

Scenario: Testing
* def detail = {\"a\":{\"data\":[{\"messa         


        
相关标签:
1条回答
  • 2020-11-30 15:21

    If you use a Scenario Outline each "row" is executed even if one fails.

    Scenario Outline: Testing
    * def detail = { a: 1, b: 2, c: 3 }
    * match detail contains <expected>
    
      Examples:
        | expected |
        | { a: 1 } |
        | { b: 2 } |
        | { c: 3 } | 
    

    Otherwise no, Karate does not have "soft" assertions.

    EDIT: note that the concept of "soft assertions" is controversial and some consider it a bad practice:

    a) https://softwareengineering.stackexchange.com/q/7823

    b) https://martinfowler.com/articles/nonDeterminism.html

    It is unlikely to be ever supported by Karate.

    For those looking for a way to show all mis-matches between 2 JSON objects, see this: https://stackoverflow.com/a/61349887/143475

    And finally, since some people want to do "conditional" match logic in JS, see this answer also: https://stackoverflow.com/a/50350442/143475

    0 讨论(0)
提交回复
热议问题