空手道在状态为201的POST请求后不显示响应

时间:2019-05-14 15:57:56

标签: json post request response karate

我正在努力进行以下测试,这通常很容易...

classifier.fit_generator(train_s, epochs=20, steps_per_epoch=100, validation_data=validation_s,
                                   validation_steps=20, class_weight=class_weights)

我应该得到一个响应,总结了我成功使用curl,Postman甚至Swagger成功获得的POST请求,但空手道未出现该响应:

Feature: Testing Env Create Feature

  Scenario Outline: Create works as intended

    Given url "http://localhost:10000/api/envs"
    And request {"name": <Name>,"gcpProjectName": <GcpProjectName>,"url": <Url>}
    When method POST
    Then status 201
    And match response contains {"id": #string, "name": <Name>,"gcpProjectName": <GcpProjectName>,"url": <Url>}

    Examples:
      | Name     | GcpProjectName                | Url              |
      | tests    | D-COO-ContinuousCollaboration | https://fake.com |
      | approval | Q-COO-ContinuousCollaboration | https://fake.com |
      | demo     | P-COO-ContinuousCollaboration | https://fake.com |
      | prod     | P-COO-ContinuousCollaboration | https://fake.com |

有人知道会发生什么吗?

感谢您的帮助。

2 个答案:

答案 0 :(得分:1)

只需在字符串替换处加上引号即可

And request {"name": "<Name>", "gcpProjectName": "<GcpProjectName>", "url": "<Url>" }

答案 1 :(得分:0)

我对您的建议也有同样的疑问,@ PeterThomas

src.test.features.envtest.env-create: [1.1:13] env-create.feature:9 - path: $, actual: '', expected: '{"name":"tests","gcpProjectName":"D-COO-ContinuousCollaboration","url":"https://fake.com"}', reason: not a sub-string

要注意的一件事是,即使我* print response,也什么也没有出现。另一方面,* print responseHeaders可以正常工作。

它与 201 状态和空手道不取回数据有关吗? 我写了很多POST测试,它们在 200 状态下都可以正常工作,但这是我写的第二篇涉及201状态和“不可见”响应的测试。