TestResponse class final

The response from a TestClient request.

response
    ..assertCreated()
    ..assertHeader('content-type', 'application/json')
    ..assertJsonContains({'item': 'shirt'});

Properties

body String
Response body decoded as UTF-8, computed once.
latefinal
bodyBytes List<int>
The response body exactly as it arrived (unmodifiable).
final
hashCode int
The hash code for this object.
no setterinherited
headers Map<String, String>
Response headers, one joined value per name (unmodifiable).
final
headersAll Map<String, List<String>>
Every value for every response header, keyed by lowercased name (unmodifiable).
final
json Object?
Decodes body as JSON, once. Throws TestAssertionError on invalid JSON.
latefinal
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
statusCode int
HTTP status code.
final

Methods

assertBadRequest() → void
  • assertBodyEmpty() → void
    Asserts empty body.
    assertConflict() → void
  • assertContainsHeader(String name) → void
    Asserts header name is present, regardless of value.
    assertCreated() → void
  • assertFailure() → void
    Asserts non-2xx.
    assertForbidden() → void
  • assertHeader(String name, String value) → void
    Asserts header name equals value.
    assertJson(Object? expected) → void
    Asserts body decodes to JSON equal to expected.
    assertJsonContains(Object? expected) → void
    Asserts decoded JSON contains expected as a subset.
    assertMethodNotAllowed() → void
  • assertNoContent() → void
  • assertNotFound() → void
  • assertOk() → void
  • assertPayloadTooLarge() → void
  • assertServiceUnavailable() → void
  • assertStatus(int expected) → void
    Asserts exact expected status.
    assertSuccess() → void
    Asserts 2xx.
    assertText(String expected) → void
    Asserts body equals expected.
    assertTextContains(String expected) → void
    Asserts body contains expected.
    assertUnauthorized() → void
  • assertUnprocessable() → void
  • assertUnsupportedMediaType() → void
  • noSuchMethod(Invocation invocation) → dynamic
    Invoked when a nonexistent method or property is accessed.
    inherited
    toString() String
    A string representation of this object.
    override

    Operators

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