spring-cloud-contract-wiremock | 自动注册存根与编程注册的对比

huangapple go评论72阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2020年8月11日 16:14:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/63354154.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定