Question about Karate test case for POST method

五迷三道 提交于 2021-02-05 08:16:27

问题


I have an endpoint URL, within Swagger I must pass certain fields to test the POST method. I was wondering if anyone had an example of how to set up a Karate test for a POST method?


回答1:


Yes, there are plenty in the documentation: https://github.com/intuit/karate

If you follow the quickstart, you will get a sample project with a working 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


来源:https://stackoverflow.com/questions/53655451/question-about-karate-test-case-for-post-method

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!