Clone this repo:
  1. 12cdc5f Update pubspec.yaml (#187) by Devon Carew · 6 weeks ago master
  2. 5c9c8de Bump actions/checkout from 2 to 3 (#186) by dependabot[bot] · 3 months ago
  3. 440e330 Add a Best Practices section to README (#185) by Nate Bosch · 3 months ago
  4. a73152f Bump version to 0.12.12-dev (#182) by Kevin Moore · 4 months ago
  5. 07595a7 fix new hint (#181) by Kevin Moore · 4 months ago

Support for specifying test expectations, such as for unit tests.

The matcher library provides a third-generation assertion mechanism, drawing inspiration from Hamcrest.

For more information, see Unit Testing with Dart.

Best Practices

Prefer semantically meaningful matchers to comparing derived values

Matchers which have knowledge of the semantics that are tested are able to emit more meaningful messages which don't require reading test source to understand why the test failed. For instance compare the failures between expect(someList.length, 1), and expect(someList, hasLength(1)):

// expect(someList.length, 1);
  Expected: <1>
    Actual: <2>
// expect(someList, hasLength(1));
  Expected: an object with length of <1>
    Actual: ['expected value', 'unexpected value']
     Which: has length of <2>