Trying Checks as a Preview

  1. Add a git dependency on this package:

    dev_dependencies:
      checks:
        git:
          url: git@github.com:dart-lang/test.git
          path: pkgs/checks
          # Omit to try the latest, or pin to a commit to avoid
          # breaking changes while the library is experimental.
          ref: <sha>
    
  2. Add an import to package:checks/checks.dart.

  3. Replace the existing package:test/test.dart import with package:test/scaffolding.dart.

  4. For an incremental migration within the test, add an import to package:test/expect.dart. Remove it to surface errors in tests that still need to be migrated, or keep it in so the tests work without being fully migrated.

  5. Migrate the test cases.

Migrating from Matchers

Replace calls to expect with a call to checkThat passing the first argument. When a direct replacement is available, change the second argument from calling a function returning a Matcher, to calling the extension method on the Check.

When a non-matcher argument is used for the expected value, it would have been wrapped with equals automatically. See below, .equals may not always be the correct replacement in package:checks.

expect(actual, expected);
checkThat(actual).equals(expected);
// or maybe
checkThat(actual).deepEquals(expected);

Differences in behavior from matcher

  • The equals Matcher performed a deep equality check on collections. .equals() check will only correspond to [operator ==] so some tests may need to replace .equals() with .deepEquals(). TODO: implement deepEquals