有关POST方法的空手道测试用例的问题

时间:2018-12-06 16:12:38

标签: unit-testing cucumber gherkin karate

我有一个端点URL,在Swagger中,我必须传递某些字段来测试POST方法。我想知道是否有人举过例说明如何为POST方法设置空手道测试?

1 个答案:

答案 0 :(得分:1)

是的,文档中有很多内容:https://github.com/intuit/karate

如果您遵循快速入门,您将获得一个带有正常POST的示例项目:https://github.com/intuit/karate#quickstart

Scenario: create a user and then get it by id

* def user =
"""
{
    "name": "Test User",
    "username": "testuser",
    "email": "test@user.com",
    "address": {
      "street": "Has No Name",
      "suite": "Apt. 123",
      "city": "Electri",
      "zipcode": "54321-6789"
    }
}
"""

Given url 'https://jsonplaceholder.typicode.com/users'
And request user
When method post
Then status 201