Running WireMock.Net without starting a server #289

Closed
opened 2025-12-29 15:19:47 +01:00 by adam · 6 comments
Owner

Originally created by @Code-Grump on GitHub (Aug 6, 2020).

Is there a way to run WireMock.Net without starting a server instance running on a physical port? It would be great to be able to create a server-less instance that exposes an HttpMessageHandler or HttpClient in a similar fashion to ASP.NET's TestServer. It would be easy to inject these properties into a system-under-test to avoid having to go over a physical network link.

Originally created by @Code-Grump on GitHub (Aug 6, 2020). Is there a way to run WireMock.Net without starting a server instance running on a physical port? It would be great to be able to create a server-less instance that exposes an `HttpMessageHandler` or `HttpClient` in a similar fashion to ASP.NET's `TestServer`. It would be easy to inject these properties into a system-under-test to avoid having to go over a physical network link.
adam added the question label 2025-12-29 15:19:47 +01:00
adam closed this issue 2025-12-29 15:19:47 +01:00
Author
Owner

@StefH commented on GitHub (Aug 6, 2020):

@Tragedian
I see your point, however WireMock.Net is created specifically (at this moment) to mock the wire and the requests and responses and can be used to mock 3rd party services.

@StefH commented on GitHub (Aug 6, 2020): @Tragedian I see your point, however WireMock.Net is created specifically (at this moment) to mock the _wire_ and the requests and responses and can be used to mock 3rd party services.
Author
Owner

@Code-Grump commented on GitHub (Aug 6, 2020):

I can see that the implementation is currently built around middleware configured using WebHostBuilder. That makes it a relatively simple job to add the middleware to a TestServer instance. Perhaps WireMockServer could be extended in some fashion to support any server capable of hosting the middleware?

@Code-Grump commented on GitHub (Aug 6, 2020): I can see that the implementation is currently built around middleware configured using `WebHostBuilder`. That makes it a relatively simple job to add the middleware to a `TestServer` instance. Perhaps `WireMockServer` could be extended in some fashion to support any server capable of hosting the middleware?
Author
Owner

@StefH commented on GitHub (Aug 7, 2020):

Maybe making WireMockMiddleware public will already solve your question?

@StefH commented on GitHub (Aug 7, 2020): Maybe making `WireMockMiddleware` public will already solve your question?
Author
Owner

@Code-Grump commented on GitHub (Aug 7, 2020):

It would be a fantastic step in that direction, certainly. The only challenge then would be configuring the middleware options, as those methods all exist on the server, not the options themselves. It probably wouldn't be hard to move some logic around to achieve that though.

@Code-Grump commented on GitHub (Aug 7, 2020): It would be a fantastic step in that direction, certainly. The only challenge then would be configuring the middleware options, as those methods all exist on the server, not the options themselves. It probably wouldn't be hard to move some logic around to achieve that though.
Author
Owner

@StefH commented on GitHub (Aug 13, 2020):

The middle ware depends on:

  • IWireMockMiddlewareOptions options
  • IOwinRequestMapper requestMapper
  • IOwinResponseMapper responseMapper
  • IMappingMatcher mappingMatcher

However code to add/configure mappings is not working because these methods are defined on the WireMock server code.

@StefH commented on GitHub (Aug 13, 2020): The middle ware depends on: - IWireMockMiddlewareOptions options - IOwinRequestMapper requestMapper - IOwinResponseMapper responseMapper - IMappingMatcher mappingMatcher However code to add/configure mappings is not working because these methods are defined on the WireMock server code.
Author
Owner

@StefH commented on GitHub (Oct 20, 2021):

Closing...

@StefH commented on GitHub (Oct 20, 2021): Closing...
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#289