NetMock class

A utility class for mocking HTTP requests and responses using http.MockClient.

NetMock is a syntactic sugar around http.MockClient which allows you to intercept HTTP requests and provide predefined responses for testing purposes. It maintains a list of mocked requests and their corresponding responses, as well as a default response for unmatched requests.

Constructors

NetMock({NetMockResponse? defaultResponse})

Properties

allowedMocks List<NetMockRequestResponse>
A list of un-intercepted requests and their corresponding responses.
no setter
client ↔ Client
latefinal
defaultResponse NetMockResponse
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
interceptedRequests List<NetMockRequest>
A list of intercepted requests that have been processed.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addMock({required NetMockRequest request, required NetMockResponse response}) → void
Adds a new mock request and response pair to the queue.
close() → void
Closes the mock client, releasing any resources.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited