testing library

This library contains testing classes for the HTTP library.

The MockClient class is a drop-in replacement for http.Client that allows test code to set up a local request handler in order to fake a server that responds to HTTP requests:

import 'dart:convert';
import 'package:http/testing.dart';

var client = MockClient((request) async {
  if (request.url.path != "/data.json") {
    return Response("", 404);
  return Response(
        'numbers': [1, 4, 15, 19, 214]
      headers: {'content-type': 'application/json'});


A mock HTTP client designed for use when testing code that uses BaseClient.


MockClientHandler = Future<Response> Function(Request request)
A handler function that receives Requests and sends Responses.
MockClientStreamHandler = Future<StreamedResponse> Function(BaseRequest request, ByteStream bodyStream)
A handler function that receives StreamedRequests and sends StreamedResponses.