英文:
spring-cloud-contract-wiremock | Registering Stubs Automatically vs Programmatically
问题
I would like to continue loading all my subs
@AutoConfigureWireMock(port = 0, stubs = "classpath:/mappings/perform-buyback")
And in some test cases on this test class, I would like to change some mock responses to simulate different scenarios.
When I run only my local test method it works fine, when I run all my class it fails. So I come to this question. Is that possible to overwrite some stub that was registered according to the documentation automatically and replace it with stubFor(get(urlEqualTo(
programmatic in each method? What should be the behavior?
英文:
I would like to continue loanding all my subs
@AutoConfigureWireMock(port = 0, stubs = "classpath:/mappings/perform-buyback")
And in some test cases on this test class, I would like to change some mock responses to simulate different scenarios.
When I run only my local test method it works fine, when I run all my class it fails. So I come to this question. Is that possible to overwrite some stub that was registered according to the documentation automatically and replace it with stubFor(get(urlEqualTo(
programmatic in each method? What should be the behaver?
答案1
得分: 2
你可以这样做,因为如果你执行 new WireMockServer(...)
,你可以传递一个运行中的 WireMock 实例的端口,然后你可以运行任何你想要的逻辑。你可以手动存根它,重置它,做任何你想做的事情。
英文:
You could do it cause if you do new WireMockServer(...)
you can pass in a port of a running WireMock instance and then you can run any logic you want. You can manually stub it, reset it, do whatever you want.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论