You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This commit was created on GitHub.com and signed with GitHub’s verified signature.
Breaking Changes
Replace the typedef Condition and AsyncCondition function type callback
arguments with a Condition class which has check, softCheck, and describe methods. Use the static it method in place of function
literals: (it) => it.someCheck() becomes .it()..someCheck(). Most
uses should have the required context type to allow the use of dot
shorthands. Within collection literals where there is no context type use Condition.it<SomeType>()..someCheck().
Remove the describe, describeAsync, softCheck, and softCheckAsync
top level methods in favor of the instance members on Condition.
Swap the positional arguments to has so the name comes first: has((v) => v.property, 'property') becomes has('property', (v) => v.property). A data driven fix is included, so dart fix --apply will update most call sites. Call sites where the
extractor argument is statically dynamic produce no analysis error and
will not be updated by the fix; these need to be found manually.
Expectation extension methods which take no arguments have been changed to
getters:
doesNotComplete
isDone
isEmpty
isFalse
isFinite
isInfinite
isNaN
isNegative
isNotEmpty
isNotFinite
isNotInfinite
isNotNaN
isNotNegative
isNull
isTrue
Remove the public constructors for CheckFailure and FailureDetail.
Updated Context.nest to accept an optional named nestedCondition argument
which is executed against the nested subject.
Updated Subject.isA, Subject.isNotNull, Subject.throws (sync), and Subject.returnsNormally to accept an optional Condition to apply
to the extracted value. For example check(foo).isA<int>(.it()..isGreaterThan(0));
Updated Subject.completes, Subject.throws (async), StreamChecks.emits,
and StreamChecks.emitsError to return Future<Subject> in addition to
accepting an optional Condition. For example (await check(foo).completes()).equals(42);
Added FutureSubjectExtension.which to allow chaining expectations on a Future<Subject>.
Added a runnable example for every expectation, linked from its
documentation.
Fix the failure message for MapChecks.isNotEmpty to say that the map is empty, instead of incorrectly repeating is not empty.
Fix the failure message for pairwiseMatches to indent the nested detail
about the element that failed, so that it is visibly part of the clause it
describes.
Fix the failure message for equalsIgnoringWhitespace to report the value
with its whitespace collapsed. The reported offset and difference always
referred to the collapsed value, but the message showed the original, so the
two did not line up.
Use a consistent lower case first word for the Which: clause of isA, IterableChecks.any, MapChecks.containsKeyThat, and MapChecks.containsValueThat.
Remove a stray trailing space from the failure message for not.
Add prints() check extensions on Subject<void Function()> and Subject<Future<void> Function()> to check expectations against captured
printed output.
Improve collapsed failure messages when the only expectation on a nested
subject is a further nested subject. The inner description is joined to the
label for the outer subject with "that", so .throws<StateError>().has('message', (e) => e.message).equals('foo') reads
as throws an error of type StateError that has message: 'foo' instead of throws has message: 'foo', and chained has calls read as has value that has field: 'foo' instead of has value: has field: 'foo'.
Collapse nested subjects with a single expectation in the output of Condition.describe, matching the format used for failure messages. For
example .it()..length.equals(1) describes as has length: <1> instead of has length that: followed by equals <1> on an indented line.
Collapse nested subjects with a single expectation at every depth of a
failure message. Previously only those directly under the subject with the
failing expectation collapsed; a passing sibling with multiple expectations
showed its own nested subjects in full, such as has length that: followed
by equals <3> instead of has length: <3>.
Collapse the failure messages for IterableChecks.any, IterableChecks.every, MapChecks.containsKeyThat, and MapChecks.containsValueThat to a single line when the condition describes
in a single line and the result fits within 80 columns, for example Expected: an iterable containing a value that is greater than <7>.
Describe IterableChecks.any, IterableChecks.every, MapChecks.containsKeyThat, and MapChecks.containsValueThat in a single
line when the condition describes in a single line and the result fits
within 80 columns, such as contains a value that is greater than <7>.
This applies where they are one of several expectations, or are nested
inside the condition of another of these expectations.
Describe the condition for IterableChecks.every as only has elements where each instead of only has values that, for
example only has elements where each is less than <10>, so that it reads
as a sentence when nested in another condition.
Fix the failure details from Condition.softCheck when a precondition such
as isA<T>() is rejected and further expectations follow it. The last
expectation was treated as the one that failed, which triggered an assertion
error, or attributed the rejection to the wrong expectation. This could be
seen in the failure message for IterableChecks.every.
Omit the expectations after the one that failed from failure messages.
Within a soft check, such as the condition for IterableChecks.every, and
after an unawaited expectation which fails later, the later expectations
were described as if the value satisfied them. This includes expectations
made while an asynchronous expectation such as completes was waiting for
its value. An asynchronous expectation which has not finished when a later
expectation fails is also left out, instead of being described as
satisfied.
Fix the failure messages for IterableChecks.every and for Condition
elements in IterableChecks.deepEquals to keep the nested property for the
element that failed, for example Actual: has field: 'foo' instead of Actual: 'foo'. deepEquals now uses the same format as every, with Which: in place of which.
Add CheckFailure.describeNested to describe a failure from soft checking
a condition within the which of another Rejection, in the same format
as a failure message from check.
Use the format of a failure message from check for the conditions that
failed in StreamChecks.inOrder, StreamChecks.anyOf, and IterableChecks.pairwiseMatches. Each failure now has an Actual: line,
which inOrder and anyOf previously omitted when the condition failed
without collapsing to a single line, and inOrder and anyOf no longer
repeat the Expected: description of the condition.
Describe what the stream did in the Actual: line of failures from StreamChecks.emits, emitsError, emitsThrough, neverEmits, and isDone, instead of a stream. For example emitsThrough reports Actual: a stream that closed after emitting ['a', 'b', 'c'] and neverEmits reports the values up to and including the matching one. Up to
the first 25 values are listed, along with the total count for a longer
stream.
Fix the failure message for StreamChecks.emitsError when the stream emits
a value, which said closed without emitting an error.
Require package:meta^1.17.0.
Use the Iterable.last member of the iterable for IterableChecks.last
instead of iterating to the final element.