Dart API ReferenceunittestMatcher

Matcher Interface

expect Matchers must implement the Matcher interface. The base Matcher class that implements this interface has a generic implementation of describeMismatch so this does not need to be provided unless a more clear description is required. The other two methods (matches and describe) must always be provided as they are highly matcher-specific.

Implemented by

BaseMatcher

Methods

Code Description describe(Description description) #

This builds a textual description of the matcher.

Description describe(Description description);

Code Description describeMismatch(item, Description mismatchDescription, MatchState matchState, bool verbose) #

This builds a textual description of a specific mismatch. item is the value that was tested by matches; matchState is the MatchState that was passed to and supplemented by matches with additional information about the mismact, and mismatchDescription is the Description that is being built to decribe the mismatch. A few matchers make use of the verbose flag to provide detailed information that is not typically included but can be of help in diagnosing failures, such as stack traces.

Description describeMismatch(item, Description mismatchDescription,
    MatchState matchState, bool verbose);

Code bool matches(item, MatchState matchState) #

This does the matching of the actual vs expected values. item is the actual value. matchState can be supplied and may be used to add details about the mismatch that are too costly to determine in describeMismatch.

bool matches(item, MatchState matchState);