11# Checking expectations with ` checks `
22
3- Expectations start with ` checkThat ` . This utility returns a ` Subject ` , and
3+ Expectations start with ` check ` . This utility returns a ` Subject ` , and
44expectations can be checked against the subject. Expectations are defined as
55extension methods, and different expectations will be available for subjects
66with different value types.
77
88``` dart
9- checkThat (someValue).equals(expectedValue);
10- checkThat (someList).deepEquals(expectedList);
11- checkThat (someString).contains('expected pattern');
9+ check (someValue).equals(expectedValue);
10+ check (someList).deepEquals(expectedList);
11+ check (someString).contains('expected pattern');
1212```
1313
1414Multiple expectations can be checked against the same value using cascade
1515syntax. When multiple expectations are checked against a single value, a failure
1616will included descriptions of the expectations that already passed.
1717
1818``` dart
19- checkThat (someString)
19+ check (someString)
2020 ..startsWith('a')
2121 ..endsWith('z')
2222 ..contains('lmno');
@@ -26,15 +26,15 @@ Some expectations return a `Subject` for another value derived from the original
2626value - for instance reading a field or awaiting the result of a Future.
2727
2828``` dart
29- checkThat (someString).length.equals(expectedLength);
30- (await checkThat (someFuture).completes()).equals(expectedCompletion);
29+ check (someString).length.equals(expectedLength);
30+ (await check (someFuture).completes()).equals(expectedCompletion);
3131```
3232
3333Fields can be extracted from objects for checking further properties with the
3434` has ` utility.
3535
3636``` dart
37- checkThat (someValue)
37+ check (someValue)
3838 .has((value) => value.property, 'property')
3939 .equals(expectedPropertyValue);
4040```
@@ -47,22 +47,22 @@ value as a subject will be recorded and replayed when it is applied as a
4747condition. The ` it() ` utility returns a ` ConditionSubject ` .
4848
4949``` dart
50- checkThat (someList).any(it()..isGreaterThan(0));
50+ check (someList).any(it()..isGreaterThan(0));
5151```
5252
5353Some complicated checks may be difficult to write with parenthesized awaited
5454expressions, or impossible to write with cascade syntax. There are ` which `
5555utilities for both use cases which take a ` Condition ` .
5656
5757``` dart
58- checkThat (someString)
58+ check (someString)
5959 ..startsWith('a')
6060 // A cascade would not be possible on `length`
6161 ..length.which(it()
6262 ..isGreatherThan(10)
6363 ..isLessThan(100));
6464
65- await checkThat (someFuture)
65+ await check (someFuture)
6666 .completes()
6767 .which(it()..equals(expectedCompletion));
6868```
@@ -126,7 +126,7 @@ extension CustomChecks on Subject<CustomType> {
126126
127127# Migrating from Matchers
128128
129- Replace calls to ` expect ` with a call to ` checkThat ` passing the first argument.
129+ Replace calls to ` expect ` with a call to ` check ` passing the first argument.
130130When a direct replacement is available, change the second argument from calling
131131a function returning a Matcher, to calling the extension method on the
132132` Subject ` .
@@ -137,9 +137,9 @@ correct replacement in `package:checks`.
137137
138138``` dart
139139expect(actual, expected);
140- checkThat (actual).equals(expected);
140+ check (actual).equals(expected);
141141// or maybe
142- checkThat (actual).deepEquals(expected);
142+ check (actual).deepEquals(expected);
143143```
144144
145145## Differences in behavior from matcher
0 commit comments