Testing utilities for Aqueduct applications

This library should be imported in test scripts. It should not be imported in application code.

Example:

import 'package:test/test.dart'; import 'package:aqueduct/aqueduct.dart'; import 'package:aqueduct/test.dart';

void main() { test("...", () async => ...); }

Constants

isBoolean → Matcher

Validates that value is a bool.

const isInstanceOf<bool>()
isDouble → Matcher

Validates that value is a double.

const isInstanceOf<double>()
isInteger → Matcher

Validates that value is an int.

const isInstanceOf<int>()
isNotPresent → Matcher

This instance is used to validate that a key does not exist in partial or HTTP response headers.

const NotPresentMatcher()
isNumber → Matcher

Validates that value is a num.

const isInstanceOf<num>()
isString → Matcher

Validates that value is a String.

const isInstanceOf<String>()

Properties

isTimestamp → Matcher

Validates that a value is a ISO8601 timestamp.

read / write

Functions

asDateTime(value) → dynamic

@Deprecated("3.0, no longer necessary")
asNumber(value) → dynamic

@Deprecated("3.0, no longer necessary")
expectResponse(TestResponse response, int statusCode, { body, Map<String, dynamic> headers }) TestResponse

Short-hand for expect and hasResponse that returns response.

hasBody(matchSpec) → Matcher

Validates that a TestResponse has the specified HTTP response body.

hasHeaders(Map<String, dynamic> matchers, { bool failIfContainsUnmatchedHeader: false }) → Matcher

Validates that a TestResponse has the specified HTTP headers.

hasResponse(int statusCode, bodyMatcher, { Map<String, dynamic> headers: null, bool failIfContainsUnmatchedHeader: false }) → Matcher

Validates that a TestResponse has the specified status code, body and headers.

hasStatus(int statusCode) → Matcher

Validates that a TestResponse has the specified HTTP status code.

isAfter(DateTime date) → Matcher

Validates that a DateTime is after date.

isAfterOrSameMomentAs(DateTime date) → Matcher

Validates that a DateTime is after or the same moment as date.

isBefore(DateTime date) → Matcher

Validates that a DateTime is before date.

isBeforeOrSameMomentAs(DateTime date) → Matcher

Validates that a DateTime is before or the same moment as date.

isSameMomentAs(DateTime date) → Matcher

Validates that a DateTime is the same moment as date.

partial(Map map) → Matcher

A matcher that partially matches a Map.

Classes

MockHTTPRequest

The 'event' type for MockHTTPServer.

MockHTTPServer

This class is used as a utility for testing.

MockServer

This class is used as a utility for testing.

TestClient

Instances of this class are used during testing to make testing an HTTP server more convenient.

TestRequest

Instances of this type represent an HTTP request to be executed with a TestClient.

TestResponse

Instances are HTTP responses returned from TestClient.

TestResponseBody

Instances of these type represent the body of a TestResponse.

Exceptions / Errors

TestClientException