简体   繁体   English

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

[英]Question about Karate test case for POST method

I have an endpoint URL, within Swagger I must pass certain fields to test the POST method.我有一个端点 URL,在 Swagger 中,我必须传递某些字段来测试 POST 方法。 I was wondering if anyone had an example of how to set up a Karate test for a POST method?我想知道是否有人有如何为 POST 方法设置空手道测试的示例?

Yes, there are plenty in the documentation: https://github.com/intuit/karate是的,文档中有很多: 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如果您遵循快速入门,您将获得一个带有有效 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM