conduit_test library Null safety

Testing utilities for Conduit 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:conduit/conduit.dart'; import 'package:conduit/test.dart';

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

Classes

Agent
Executes HTTP requests during application testing.
MockHTTPServer
This class is used as a 'mock' implementation of another HTTP server.
MockServer<T>
This class is used as a utility for testing.
TestHarness<T extends ApplicationChannel>
Manages application lifecycle for the purpose of testing the application.
TestHarnessAuthMixin<T extends ApplicationChannel>
Use methods from this class to test applications that use AuthServer for authentication & authorization.
TestHarnessORMMixin
Use methods from this class to test applications that use the Conduit ORM.
TestRequest
Object to construct and execute an HTTP request during testing.
TestResponse
An HTTP response from a test application.
TestResponseBody
Instances of these type represent the body of a TestResponse.

Constants

isBoolean → const TypeMatcher<bool>
Validates that value is a bool.
TypeMatcher<bool>()
isDouble → const TypeMatcher<double>
Validates that value is a double.
TypeMatcher<double>()
isInteger → const TypeMatcher<int>
Validates that value is an int.
TypeMatcher<int>()
isNotPresent → const Matcher
Validates that a key is not present when using partial.
NotPresentMatcher()
isNumber → const TypeMatcher<num>
Validates that value is a num.
TypeMatcher<num>()
isString → const TypeMatcher<String>
Validates that value is a String.
TypeMatcher<String>()

Properties

isTimestamp Matcher
Validates that a value is a ISO8601 timestamp.
read / write

Functions

expectResponse(TestResponse? response, int statusCode, {dynamic body, Map<String, dynamic>? headers}) TestResponse?
A convenience for expect with hasResponse.
hasBody(dynamic bodyMatcher) Matcher
Validates that TestResponse has a decoded body that matches bodyMatcher.
hasHeaders(Map<String, dynamic> headerMatcher, {bool failIfContainsUnmatchedHeader = false}) Matcher
Validates that TestResponse has headers that match headerMatcher.
hasResponse(int? statusCode, {dynamic body, Map<String, dynamic>? headers, bool failIfContainsUnmatchedHeader = false}) Matcher
Validates that TestResponse has matching statusCode, body, and headers.
hasStatus(int statusCode) Matcher
Validates that TestResponse has a status code of statusCode.
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<String, dynamic> map) Matcher
A matcher for maps that only checks the values of the provided keys.