-
-
Notifications
You must be signed in to change notification settings - Fork 214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WireMock.Net not responding in unit tests - same works in console application #122
Comments
When using wiremock in unit tests, you should not use a fixed port. Use code like this: // given
_server = FluentMockServer.Start();
_server.Given(Request.Create().WithPath("/foo").UsingVerb("patch"))
.RespondWith(Response.Create().WithBody("hello patch"));
// when
var msg = new HttpRequestMessage(new HttpMethod("patch"), new Uri("http://localhost:" + _server.Ports[0] + "/foo"))
{
Content = new StringContent("{\"data\": {\"attr\":\"value\"}}")
};
var response = await new HttpClient().SendAsync(msg); The wiki is somewhat confusing. I will update this in the weekend. |
Thank you for response. Couple of questions from above request
We've attempted to start server without specifying any port. However the behavior remained same
It's important for us to read static mapping from specified location. Code we're trying with var server1 = FluentMockServer.Start(); Any thoughts ? Thanks. |
|
Thank you. This is working now. However one last point worth mentioning - when i execute unit test in debug mode, even though isStarted is set to true, i can't access the mockserver through browser until the continue debug. Is that expected ? |
Probably expected, maybe not all async code is really listening. |
Dear Team,
In a console application, I've below code to start WireMock.Net
// setup
var server1 = FluentMockServer.Start(new FluentMockServerSettings
{
Urls = new[] { "http://localhost:9091" },
ReadStaticMappings = true,
StartAdminInterface = true
});
This works all good.
When i write same in Unit tests, WireMock.Net does not respond
It's mandatory for us to use port (i've referred to https://github.com/WireMock-Net/WireMock.Net/wiki/Using-WireMock-in-UnitTests)
Thanks in advance
The text was updated successfully, but these errors were encountered: