服务虚拟化-空手道 [英] Service Virtualization - Karate
问题描述
服务虚拟化的新手,但是在我进行研究时,我注意到Karate也对此提供了一些支持.由于我已经在使用它,所以很好奇它是否适合需要.我正在尝试使用一些重试逻辑来测试调用另一个API B的APIA.该请求不会更改,但是B可能会发送带有错误消息或成功消息的响应正文.目的是重试x次,直到整体看到成功失败为止.所以,问题是我如何在该测试中模拟B的响应?当然,A提出的请求将保持不变.
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.
推荐答案
空手道很容易做到这一点.您可以设置全局"模拟中的变量,该变量将保留调用次数的计数.其余的是正常"的.空手道.
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.
您应该阅读文档.如果需要,请询问一个单独的特定问题: https://stackoverflow.com/a/61374079/143475
You should read the docs. Ask a separate specific question if needed: https://stackoverflow.com/a/61374079/143475
这篇关于服务虚拟化-空手道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!