karate icon indicating copy to clipboard operation
karate copied to clipboard

karate mock server interceptor

Open sergy8612 opened this issue 7 months ago • 6 comments

Hi @ptrthomas

From this question https://stackoverflow.com/questions/77346337/karate-test-framework-are-there-plans-to-include-runtimehooks-for-mockserver we open this issue.

In our case, we need to implement an interceptor in mock http server to track the requests-responses and the scenario and gather all that info to generate a report, with the scenario, the request and response, to validate them against a swagger (we use https://pactflow.io/ which needs to track the request and responses from the mock server to validate the contracts) and in the validation we need not only the http request and response, but the scenario in the mockserver as well. This allows us to generate the report and the Contract Test in our component tests and in our case saves us lots of work.

Unfortunately we don't have that kind of hook .

I created this interface as a hook which meets these needs by extending the karate MockHandler and MockServer

image

Then I included this interceptor interface as a hook in our customzed mockserver image

image

For these reasons, I'd like to create a pull request as a contribution by including the possibility of adding this intereptor

sergy8612 avatar Nov 09 '23 21:11 sergy8612