Search code examples
javascriptnode.jsintegration-testingswaggercode-generation

api integration test code generation from swagger spec


​Hi everyone,

My list of API resources/endpoints has really grown over the months and I have foolishly neglected writing integration tests for most of these APIs. The list of APIs continues to grow and consequently, I have a strong need for integration test code generation.

Luckily, all of my APIs are described in a v2.0 swagger.json spec, and I've found a few frameworks/modules for generating test code:

https://www.npmjs.com/package/swagger-test

https://github.com/apigee-127/swagger-test-templates

https://github.com/apigee-127/swagger-testing

My question to the community is, which framework/module for api integration test code generation have you found to be the overall best? Two important notes in my case:

  1. Integration test code generated must be written in node.js
  2. I have lots of different APIs which require different JSON request data, and I would need to generate/mock and insert said JSON data into the outgoing test HTTP messages.
  3. The tests need to send HTTP messages to an external host running the API application (i.e. NOT localhost).

Thanks in advance for any and all help/insight!

Best,

Chris

UPDATE: After some research and trial/error, I've found that https://github.com/apigee-127/swagger-test-templates is the most robust and full-featured option. If anyone has any opinions on this module, please share!


Solution

  • I decided to go with the oatts module:

    https://github.com/google/oatts

    https://google.github.io/oatts/

    This seemed to be a much more evolved version of the swagger-test-templates module, and it was self advertised as such :)

    I was able to successfully generate quite a bit of quality test code using the oatts module.

    Best,

    Chris