Testing RESTful APIs with Swagger

I am trying to develop an automated test suite for the REST API. I was told that Swagger would be the right tool for this. The API is being developed using the Spring Framework.

I cannot figure out how to use Swagger for this. In my opinion, Swagger is used to create good API documentation. I looked at this Dreamfactory blog post and it looks like they have some kind of browser validation feature, but I don’t think it really is a test suite.

I also looked at ServiceStack (and the cucumber), but since its a different structure, I don't think this will work.

This discussion in the google group did not show anywhere in particular.

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

Thanks!

+9
source share
4 answers

Swagger allows you to document your API well and helps you perform manual, live tests with swagger-ui, as you can easily fill in the arguments and view the answers through the ui web interface. Try the Swagger demo as an example of what I mean. http://petstore.swagger.io/

I have not tried this, but it may be of interest for more automated testing against Swagger. https://github.com/Maks3w/SwaggerAssertions

+8
source

As mentioned in other answers, Swagger provides a way to define and document your API endpoints, methods, answers, errors, and more. It does not perform any automatic tests out of the box.

However, there are several tools that can read the Swagger definition for automated tests created:

  • Assertible is a tool into which you can import your Swagger specification to automatically create tests and assertions for each endpoint and method. You can then configure monitoring, post-deployment testing and alerts. (Read the blog Testing API with Swagger ). He has a free plan with the ability to upgrade for additional tests.
  • Swagger-test is an NPM package if you are looking for something that can be integrated with your code. I personally have not used this, but it looks active and helpful.
  • Dredd is another really cool open source tool that automates testing your Swagger specification on a real backend. It is also a CLI, and it works with the Blueprint API in addition to Swagger .

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

Another answer mentions the Commercial Tools page on the swagger.io website, which has a few more hosted services (free and paid).

Full disclosure. I am one of the co-founders of Assertible and would like to hear your feedback if you have the opportunity to use them.

+14
source

You can find a lot of software using the Swagger specification for (automated) testing your REST API at http://swagger.io/commercial-tools/ . But they are not free.

+2
source

Postman is a great test tool with Apis Swagger. It can also store requests and responses. See https://www.getpostman.com/docs/importing_swagger below for more details.

You can also see the community tools according to the languages ​​on this page. http://swagger.io/open-source-integrations/

0
source

All Articles