WireMock: Not able to mock url path only regardless the query parameters
See original GitHub issueIt’s not possible to mock url path only using WireMock solution Zerocode provide for step scenarios. Because of that it’s not possible to mock a simple url without considering the query parameters. This is easily fixed by using WireMock method called urlPathEqualTo(url)
more here.
Solution: A simple and easy solution would be to change RestEndPointMocker.class
to use urlEqualTo(url)
if the url has query parameters and urlPathEqualTo(url)
if the url doesn’t have query parameters. To check if url has parameters we can just check for ?
character is placed in the url.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Advanced Stubbing | WireMock
It's usually a good idea to use path only URL matching with query parameter matches. When multiple match clauses are added a request...
Read more >Wiremock - "URL does not match" even though it is same
Found the reason.. WireMock.urlPathEqualTo("/test/url?bookingCode=XYZ123&lastName=TEST") should not have query params.
Read more >Postman Mock Server vs. MockLab
A comparison of Postman mock servers and MockLab for building mock ... so it's possible to include URL path elements, query parameters, ...
Read more >How to Use Mock Services For Testing in BlazeMeter
Request matching could be defined by the exact match of the URL path, HTTP operation, by query parameters, request headers, request body, ...
Read more >Introduction to WireMock - Baeldung
WireMock is a library for stubbing and mocking web services. ... In case no arguments are provided, the server host defaults to localhost ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@MrXavier thanks for clarification. if you make url
"url": "cart/price?param1=param1"
it should work.Hello @sparrowV, I’m talking about mocking only the path of a http request, disregarding the query parameters. For instance, if I mock the path
cart/price
, then the requestcart/price?para1=value1¶m2=value2
won’t be matched and the mock’s response won’t be returned.Example of a mock step scenario that should work for the path
cart/price
regardless the query params but currently isn’t working.Hope this helps.