mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-23 00:38:28 +02:00
Updated What Is WireMock.Net (markdown)
@@ -1,14 +1,14 @@
|
|||||||
# What Is WireMock?
|
# What Is WireMock.Net?
|
||||||
WireMock is a tool which mimics the behaviour of an HTTP API, it captures the HTTP requests and sends it to WireMock HTTP server, which is started and as a result, we can setup expectations, call the service and then verify its behaviour.
|
WireMock.Net is a tool which mimics the behaviour of an HTTP API, it captures the HTTP requests and sends it to WireMock.Net HTTP server, which is started and as a result, we can setup expectations, call the service and then verify its behaviour.
|
||||||
|
|
||||||
# When Should We Use WireMock?
|
# When Should We Use WireMock.Net?
|
||||||
Below are three situations when we should use WireMock:
|
Below are three situations when we should use WireMock.Net:
|
||||||
|
|
||||||
#### 1. `HTTP Dependencies Not Ready`
|
#### 1. `HTTP Dependencies Not Ready`
|
||||||
|
|
||||||
An engineering team needs to implement a feature which uses an HTTP API that is not ready, this occurs often in an microservice based architecture.
|
An engineering team needs to implement a feature which uses an HTTP API that is not ready, this occurs often in an microservice based architecture.
|
||||||
|
|
||||||
To avoid engineering waste, you can mimic the behaviour of the HTTP API using WireMock and then replace the call to WireMock API to the actual API.
|
To avoid engineering waste, you can mimic the behaviour of the HTTP API using WireMock.Net and then replace the call to WireMock.Net API to the actual API.
|
||||||
|
|
||||||
#### 2. `Unit Test classes which use HTTP APIs`
|
#### 2. `Unit Test classes which use HTTP APIs`
|
||||||
|
|
||||||
@@ -32,22 +32,22 @@ External HTTP API cannot initialise into a known state before the tests are run.
|
|||||||
|
|
||||||
`Slow tests`
|
`Slow tests`
|
||||||
|
|
||||||
External HTTP API takes longer than getting the same response from WireMock and we cannot use a short timeout because the test will fail, when the call is timed out.
|
External HTTP API takes longer than getting the same response from WireMock.Net and we cannot use a short timeout because the test will fail, when the call is timed out.
|
||||||
|
|
||||||
`API Requests Blocked`
|
`API Requests Blocked`
|
||||||
|
|
||||||
Wrong network connection, the API request which does not come from a known IP address is blocked.
|
Wrong network connection, the API request which does not come from a known IP address is blocked.
|
||||||
|
|
||||||
##### To write fast and consistent tests for HTTP APIs we should be using WireMock.
|
##### To write fast and consistent tests for HTTP APIs we should be using WireMock.Net.
|
||||||
|
|
||||||
##### However, WireMock cannot guarantee that our application is compatible with the consumed HTTP API.
|
##### However, WireMock.Net cannot guarantee that our application is compatible with the consumed HTTP API.
|
||||||
|
|
||||||
The WireMock tests will ensure
|
The WireMock.Net tests will ensure
|
||||||
1. Our application sends the expected requests to the used HTTP API.
|
1. Our application sends the expected requests to the used HTTP API.
|
||||||
2. Our application is working as expected when it receives an expected response from the HTTP API.
|
2. Our application is working as expected when it receives an expected response from the HTTP API.
|
||||||
It is important that our expectations are correct otherwise those tests can be false positive.
|
It is important that our expectations are correct otherwise those tests can be false positive.
|
||||||
|
|
||||||
# Summary of what WireMock Offers
|
# Summary of what WireMock.Net Offers
|
||||||
1. Configure the response returned by the HTTP API when it receives a specific request.
|
1. Configure the response returned by the HTTP API when it receives a specific request.
|
||||||
2. Capture the incoming HTTP requests and write assertions for that requests.
|
2. Capture the incoming HTTP requests and write assertions for that requests.
|
||||||
3. Identify the stubbed or captured HTTP requests by using request matching
|
3. Identify the stubbed or captured HTTP requests by using request matching
|
||||||
@@ -58,4 +58,4 @@ It is important that our expectations are correct otherwise those tests can be f
|
|||||||
7. Record and Playbacks
|
7. Record and Playbacks
|
||||||
8. Support edge case failures & reduce build times
|
8. Support edge case failures & reduce build times
|
||||||
|
|
||||||
**Note**: this page is copied from https://github.com/AdriseYounis/WireMock/blob/master/README.md
|
**Note**: this page is copied from https://github.com/AdriseYounis/WireMock.Net/blob/master/README.md
|
||||||
Reference in New Issue
Block a user