File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -1391,8 +1391,18 @@ Testing HTTP Clients and Responses
1391
1391
----------------------------------
1392
1392
1393
1393
This component includes the ``MockHttpClient `` and ``MockResponse `` classes to
1394
- use them in tests that need an HTTP client which doesn't make actual HTTP
1395
- requests.
1394
+ use them in tests that shouldn't make actual HTTP requests. Such tests can be
1395
+ useful, as they are faster and consistent due to not being dependant on
1396
+ external service the request would be sent to. In result there is no need to
1397
+ worry about the service being online or the request changing some state,
1398
+ for example deleting a resource.
1399
+
1400
+ ``MockHttpClient `` implements the ``HttpClientInterface ``, just like any actual
1401
+ HTTP client in this component. You can use the interface to accept real client
1402
+ in your code, while replacing it with ``MockHttpClient `` in the test.
1403
+
1404
+ When the ``request `` method is used on ``MockHttpClient ``, it will respond with
1405
+ supplied ``MockResponse ``. There are few ways to use it:
1396
1406
1397
1407
The first way of using ``MockHttpClient `` is to pass a list of responses to its
1398
1408
constructor. These will be yielded in order when requests are made::
You can’t perform that action at this time.
0 commit comments