空手道Concat比赛中有两个回应

时间:2020-10-21 17:56:36

标签: match karate

请我需要帮助,如何联系json的两个回复消息? (姓名或姓氏)

[print] [
    {
    "bindingFailure": false,
    "code": "NotEmpty",
    "field": "name",
    "defaultMessage": "Name is empty",
...

[print] [
    {
    "bindingFailure": false,
    "code": "NotEmpty",
    "field": "surname",
    "defaultMessage": "Surname is empty",
...

功能及其:

Scenario Outline:    
...
When method POST
Then status 400
And match $.status == 400
And match each response.errors contains { defaultMessage: 'Name is empty'} || { defaultMessage: 'Surname is empty'}

Examples:
| Name   | Surname  |
| ''     | Smith    |
| Joe    | ''       |

任何想法可能有什么问题吗?

谢谢!

1 个答案:

答案 0 :(得分:0)

也许您错过了此选项:

And match each response.errors contains { defaultMessage: '#(Expected)' }

Examples:
| Name   | Surname  | Expected         |
| ''     | Smith    | Name is empty    |
| Joe    | ''       | Surname is empty |

但是,也不要过载测试。请仔细阅读以下内容:https://stackoverflow.com/a/54126724/143475

另请参阅:https://stackoverflow.com/a/50350442/143475