mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 21:10:32 +01:00
Full path required in Stub #51
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @jvandervelden on GitHub (Nov 22, 2017).
Originally assigned to: @StefH on GitHub.
Hi,
I am trying to mock out some api that my test is hitting. When I use a relative path in 'Request.Create().WithUrl()' and then try and hit the endpoint, I get a 'Mapping was not found' error and a 404. If I specify the full path 'http://localhost:port/path' it works.
Looking at the documentation, using a relative path should be possible.
Below are 2 methods I created to do a simple request. The test 'TestHttpMockServerGood' passes and the test 'TestHttpMockServerFail' fails. The fail function uses a relative path in the WithUrl function where the good function uses a full path in the WithUrl funciton.
Environment:
Visual Studio 2017
Dot Net Core 2.0
Wiremock 1.0.2.7
Am I missing anything?
@StefH commented on GitHub (Nov 22, 2017):
Hi.
You need to use a wildcard in the first test.
Like
WithUrl("*/test");See also linked unit tests : https://github.com/WireMock-Net/WireMock.Net/blob/master/test/WireMock.Net.Tests/RequestTests.Url.cs#L12
@jvandervelden commented on GitHub (Nov 22, 2017):
Thanks, I think I figured out where my confusion came from. On this wiki page (https://github.com/WireMock-Net/WireMock.Net/wiki/Using-WireMock-in-UnitTests) it shows that you are able to use a relative path with the 'WithUrl' function. I then dug into this page (https://github.com/WireMock-Net/WireMock.Net/wiki/Stubbing-and-Request-Matching) and glossed over the 'WithPath' function that I should've been using.
The (https://github.com/WireMock-Net/WireMock.Net/wiki/Using-WireMock-in-UnitTests) should be updated with either 'WithUrl("*/foo")' or 'WithPath("/foo")' to avoid future confusion.
@StefH commented on GitHub (Nov 23, 2017):
I've updated WIKI.