Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
707 views
in Technique[技术] by (71.8m points)

rest - RESTful API Testbed with Swagger

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.

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.

I've also taken a look at ServiceStack( and cucumber) but since its another framework I don't think it would work.

This google group discussion didn't see to point anywhere in particular either.

So, does anyone know how to develop a RESTful API testbed using Swagger?

Thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

As the other answers have mentioned, Swagger provides a way to define and document your API endpoints, methods, responses, errors, and more. It does not do any sort of automated testing out of the box.

There are a few tools that can read a Swagger definition to created automated tests, though:

  • Assertible is a tool where you can import your Swagger spec to automatically create tests and assertions for every endpoint and method. You can then set up monitoring, post deployment testing, and alerts. (Read the blog Testing an API using Swagger). It has a free plan with options to upgrade for more tests.
  • swagger-test is an NPM package, if you're looking for something to integrate with your code. I haven't personally used it, but it does look active and useful.
  • Dredd is another really cool open-source tool that will automate testing your Swagger spec against a live backend. This is also a CLI too, and it works with API Blueprint in addition to Swagger.

There's others as well, because Swagger provides a good common language for API developers there's some great tools that are written on top of it.

Another answer mentioned to check out the Commercial Tools page on swagger.io, which has some more hosted services (free and paid).

Full disclosure - I'm one of the co-founders of Assertible and would love to hear your feedback if you get a chance to use it.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...