Search code examples
karateservice-virtualization

Service Virtualization - Karate


New to service virtualization but while I was researching I noticed that Karate has some support for it too. Since I'm already using it, I'm curious to see if it would fit the need. I am trying to test my API A which calls upon another API B, with some retry logic. The request doesn't change, but B might send a response body with an error message or a success message. The intent is to retry x times until we see a success of fail overall. So, the question is how can i mock the response of B in this test? The request being made by A ofcourse would remain the same.


Solution

  • Karate can easily do this. You can set up a "global" variable in your mock that will keep a count of the number of times called. The rest is "normal" Karate.

    You should read the docs. Ask a separate specific question if needed: https://stackoverflow.com/a/61374079/143475