smocker-dev / smocker

Smocker is a simple and efficient HTTP mock server and proxy
https://smocker.dev
MIT License
1.13k stars 59 forks source link

Q regarding contract testing #271

Closed vposham closed 1 year ago

vposham commented 1 year ago

Thanks a lot for this awesome tool. I've been using it to write narrow integration tests by spinning smocker in Docker every time I need to run some tests with SetupSuite function to setup the mocks. As the mocks are only stored in filesystem in Smocker, I currently store them in repository and load them on test startup.

Eventually, I think the mocks gets outdated at some stage. Is it possible to leverage the created yaml mocks to perform some sort of Contract testing?

It doesn't have to be necessarily this tool tackling this issue - But Im curious on how (the process) that could be tackled as this tool already has the mocks.

gwleclerc commented 1 year ago

Hi, For me, you have at least two ways to do it:

  1. Make a small tool to check the compliance of your mocks against OpenAPI schemas (or other contract formats) and play it continuously to make sure that your mocks are still compatible with the latest version of your APIs specs.

  2. Set up requirements management on your project and attach your mocks to business requirements through header comments then use some traceability to determine which mock files are impacted by features connected to these requirements

vposham commented 1 year ago

Thanks for the response @gwleclerc. I think option 1 is more feasible to me. Please feel free to close this.