RequestExpectation

Base class for handling request and response expectations. This class provides a context manager to wait for specific network requests and responses based on a URL pattern. It sets up handlers for request and response events and provides properties to access the request, response, and response body.

Parameters

urlPattern

The URL pattern to match requests and responses.

Inheritors

Properties

Link copied to clipboard
abstract val urlPattern: Regex

Functions

Link copied to clipboard
abstract suspend fun getRawResponseBody(): EncodedBody

Fetches the raw response body once it has been received.

Link copied to clipboard
abstract suspend fun getRequest(): Network.Request

Returns the request once it has been received.

Link copied to clipboard

Returns the request event once it has been received.

Link copied to clipboard
abstract suspend fun getResponse(): Network.Response

Returns the response once it has been received.

Link copied to clipboard
inline suspend fun <T> RequestExpectation.getResponseBody(): T

Fetches the response body once it has been received.

Link copied to clipboard

Returns the response event once it has been received.

Link copied to clipboard
abstract suspend fun <T> use(block: suspend RequestExpectation.() -> T): T

Expect a request/response that matches the given urlPattern.