问题描述
我正在尝试为REST API开发自动化测试套件.有人告诉我Swagger是用于执行此操作的正确工具.该API正在使用Spring框架进行开发.
I'm trying to develop an automated testing suite for a REST API. I've been told that Swagger would be the right tool to use to do this.The API is being developed using the Spring Framework.
我不知道如何使用Swagger来做到这一点.根据我的理解,Swagger用于创建不错的API文档.我看过此Dreamfactory博客文章,看起来他们已经具有某种浏览器测试功能,但我认为它并不是真正的测试套件.
I can't figure out how I would use Swagger to do this.From my understanding Swagger is used to create nice API documentation.I've looked at this Dreamfactory blog post and it looks like they've got some kind of in browser testing functionality, but I don't think its really a test suite.
我也研究了ServiceStack(和黄瓜),但是由于它是另一个框架,所以我认为它不会起作用.
I've also taken a look at ServiceStack( and cucumber) but since its another framework I don't think it would work.
此 Google小组讨论没有指出尤其是在任何地方.
This google group discussion didn't see to point anywhere in particular either.
那么,有谁知道如何使用Swagger开发RESTful API测试平台?
So, does anyone know how to develop a RESTful API testbed using Swagger?
谢谢!
推荐答案
Swagger可让您很好地记录API,并通过swagger-ui进行手动的实时测试,因为您可以轻松地填写参数并查看通过网络用户界面进行响应.尝试Swagger演示作为我所指的示例. http://petstore.swagger.io/
Swagger will let you nicely document your API, and will help you do manual, live tests with swagger-ui in that you can easily fill in arguments and see the responses through a web ui. Try the Swagger demo as an example of what I am referring to. http://petstore.swagger.io/
我还没有尝试过,但是对于针对Swagger定义的更自动化的测试,这可能会很有趣. https://github.com/Maks3w/SwaggerAssertions
I have not tried this, but this might be of interest for more automated testing against Swagger definitions.https://github.com/Maks3w/SwaggerAssertions
这篇关于Swagger的RESTful API测试平台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!