有关POST方法的空手道测试用例的问题 [英] Question about Karate test case for POST method
本文介绍了有关POST方法的空手道测试用例的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个端点URL,在Swagger中,我必须传递某些字段来测试POST方法.我想知道是否有人举过例说明如何为POST方法设置空手道测试?
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?
推荐答案
是的,文档中有很多内容: https://github.com/intuit/karate
Yes, there are plenty in the documentation: https://github.com/intuit/karate
如果您遵循快速入门,您将获得一个带有可用POST的示例项目: https://github.com/intuit/karate#quickstart
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
这篇关于有关POST方法的空手道测试用例的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文