-
-
Notifications
You must be signed in to change notification settings - Fork 212
Using WireMock.Net.Testcontainers
Stef Heyenrath edited this page Jun 6, 2023
·
5 revisions
WireMock.Net.Testcontainers uses Testcontainers for .NET to spinup a docker container directly from the C# (unittest) code.
This options requires docker service running locally.
Both the Linux and the Windows version from WireMock.Net are supported.
To build a container and startup this container, use this code:
var container = new WireMockContainerBuilder()
.WithAutoRemove(true)
.WithCleanUp(true)
.Build();
await container.StartAsync().ConfigureAwait(false);
The following builder methods are available for the WireMockContainerBuilder
:
Method | Example | What |
---|---|---|
WithMappings |
.WithMappings(@"C:\example\\mappings") |
Specifies the path for the (static) mapping json files. |
WithWatchStaticMappings |
.WithWatchStaticMappings(true) |
Watch the static mapping files + folder for changes when running. |
WithAdminUserNameAndPassword |
.WithAdminUserNameAndPassword("x", "y") |
Set the admin username. and password for the container (basic authentication). |
Follow the tutorial here and make sure to use WireMock.Net container instead of the container used in that example.
- Home
- What is WireMock.Net
- WireMock.Org
- References
- Settings
- Admin REST API
- Proxying
- Stubbing
- Webhook
- Request Matching
- Response Templating
- Unit Testing
- Using WireMock
- Advanced
- Errors