Comments (7)
@adrianiftode
Sounds like an interesting idea.
I guess you are using a modern .NET version like 6 or higher?
There is already an internal class named WireMockMiddleware
which I register in the AspNetCoreSelfHost.cs:
appBuilder.UseMiddleware<WireMockMiddleware>();
Maybe that can be used?
from wiremock.net.
Yes, but the reason for asking this is I would like to deploy it with the tested service.
I have a service ServiceB that I would like to mock.
Then I have the client service, ServiceA, that will do requests to ServiceB. ServiceB is an external (and expensive and legacy) service, and the only way to use it in test scenarios is to mock it.
I want to configure WireMock inside ServiceA. So when ServiceA is started, the Mocked ServiceB is also started and ready to accept requests. The Mock should listen to any HTTP request to a path that starts with /service-b-mock
.
I will give it a try to the WireMockMiddleware.
To expand this, I would also like to deploy a WireMock image configured with different mocked services
- appBuilder.UseMiddleware("service-b")
- appBuilder.UseMiddleware("service-c");
This image is then deployed and accessible from the Sandbox/Tests servers, and it has some kind of "mock isolation". So each path prefix has its own WireMock configuration.
from wiremock.net.
A quick question:
Why not deploy 1 (or multiple) docker container(s) of WireMock.Net ?
from wiremock.net.
Even deploying it within a separated container, I was hoping to be a single one. I think I will go with this route anyway (multiple containers, one per every mocked service)
from wiremock.net.
Or use one container and register the mappings with a prefix in the path?
from wiremock.net.
Why not just use wiremock as a docker container using docker compose, see https://github.com/matteus6007/MyDomain.Api.Template/blob/main/docker-compose.dev-env.yml#L58 as an example of setting this up, then add your mocks in the normal JSON format into the __files
folder and change any paths in your config to http://localhost:8081/api-name/
where api-name
is a unique name for each API you want to mock. Doing it like this means you don't have to add anything specific to your code.
from wiremock.net.
I actually built this as a combination of a .NET HostedService (for Wiremock Server) and a DelegatingHandler which checks the original request headers for something like "X-WireMockStatus" and then rerouted all HttpClient calls to WireMockServer. This worked well to allow me to run this WireMockServer in all our lower environments for testing purposes.
from wiremock.net.
Related Issues (20)
- Is there a way to access templated data after transformation? HOT 3
- How does WithBody work with request matchers? HOT 5
- Save proxied requests during an XUnit integration test? HOT 7
- Wiremock.net (C#) how to get a PDF from a Request body (form-data ) HOT 2
- External Mapping Storage HOT 21
- Dynamic http status code? HOT 4
- Split WireMock into multiple nuget packages depending on features HOT 5
- Proxying always goes to the root HOT 1
- FluentAssertions extensions do not filter headers correctly HOT 2
- FluentAssertions extensions are not open for extension HOT 2
- Support for multipart formdata in RequestMessage HOT 8
- ProtoBufMatcher not working when proto package name contains dots HOT 2
- ProtoBufMatcher import in proto not working HOT 4
- Use mocked response data in Webhook body data HOT 3
- Compilation Error due to 'MessageOptions' Type Conflict between 'Google.Protobuf' and 'WireMock.Net' HOT 4
- FluentAssertions - Actual body is not displayed in error message when using Json Body HOT 6
- Did the ThrowExceptionWhenMatcherFails option got removed from 1.5.16 to 1.5.51? HOT 4
- Regex support for JsonMatcher HOT 10
- Wiremock not working with NUnit3 in .Net Framework 4.6.1 after Wiremock 1.5.47 HOT 3
- Feature: support multipart body in `IRequestMessage` HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wiremock.net.