mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 13:00:33 +01:00
Page:
Faults
Pages
Admin API Reference
Compatibility WireMock.org
Conflict on Microsoft.CodeAnalysis.CSharp
Cors
Could not load file or assembly RestEase
Development Information
Faults
FluentAssertions
Home
KestrelServerOptions
Mapping
MimeKit and MimeKitLite
MyGet preview versions
Pact
Proxying
References
RegexExtended
Request Matcher FormUrlEncodedMatcher
Request Matchers
Request Matching CSharpCode
Request Matching GraphQLMatcher
Request Matching JsonMatcher
Request Matching JsonPartialMatcher
Request Matching JsonPartialWildcardMatcher
Request Matching JsonPathMatcher
Request Matching MimePartMatcher
Request Matching ProtoBuf
Request Matching Tips
Request Matching
Response Templating
Scenarios and States
Settings
Stubbing
Using HTTPS (SSL)
Using WireMock in UnitTests
Using WireMock.Net.Aspire
Using WireMock.Net.Testcontainers
Webhook
What Is WireMock.Net
WireMock as a (Azure) Web App
WireMock as a Windows Service
WireMock as a standalone process
WireMock as dotnet tool
WireMock commandline parameters
WireMock.Org
Xamarin Could not load file or assembly
Clone
2
Faults
Stef Heyenrath edited this page 2020-01-25 09:45:40 +01:00
Table of Contents
Faults
WireMock.Net has some limited support for simulating random faults / corrupted responses.
Fault types
These faults are currently supported
- EMPTY_RESPONSE: Return a completely empty response.
- MALFORMED_RESPONSE_CHUNK: Send an OK status header, then garbage, then close the connection.
Percentage
It's also possible to define a percentage (value between 0 and 1) when this fault should occur.
Examples
C# Example
var server = WireMockServer.Start();
server
.Given(Request.Create().WithPath("/fault").UsingGet())
.RespondWith(Response.Create()
.WithStatusCode(201)
.WithHeader("Content-Type", "application/json")
.WithBody(@"{ ""result"": 100 }")
.WithFault(FaultType.MALFORMED_RESPONSE_CHUNK, 0.5));
JSON Mapping Admin interface
{
"Guid": "a51b78ac-1300-4125-aa97-d48953deef77",
"Request": {
"Path": {
"Matchers": [
{
"Name": "WildcardMatcher",
"Pattern": "/fault"
}
]
}
},
"Response": {
"StatusCode": 201,
"BodyAsJson": {
"result": 100
},
"Fault": { "Type": "MALFORMED_RESPONSE_CHUNK", "Percentage": 0.5},
"Headers": {
"Content-Type": "application/json"
}
}
}
Pages
- 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