空手道DSL空白响应通过测试

时间:2019-02-28 20:03:21

标签: rest cucumber karate

我有点困惑为什么我的测试通过了。我对我认为响应应该返回的内容做了一些断言。我的状态为200,回复为空。以下所有断言都通过了:

    When method get
    * print response
    Then status 200
    And match response == '#notnull'
    And match each $[*] == { caption : '#string' }
    And match each $[*] contains { source : '#object' }
    And match each $[*].source contains {channels : '#present' }
    And match each $[*] contains { post : '#object' }

测试输出:

12:59:30.258 [main] INFO  com.dataminr.karate - [print] [
]

1 Scenarios (1 passed)
14 Steps (14 passed)
0m2.539s

1 个答案:

答案 0 :(得分:1)

match each将始终传递一个空数组。可以将它想象为乘以0。

只需添加:

And match response != []

或:

And match response != '#[0]'