Subject<T> class
final
A target for checking expectations against a value in a test.
A subject may have a real value, in which case the expectations can be validated or rejected; or it may be a placeholder, in which case expectations describe what would be checked but cannot be rejected.
Expectation methods are defined in extensions on Subject, specialized on
the generic T.
Expectation extension methods can use the ContextExtension to interact
with the Context for this subject.
Create a subject that throws an exception for missed expectations with the check function.
Properties
-
context
→ Context<
T> -
Available on Subject<
The expectations and nesting context for this subject.T> , provided by the ContextExtension extensionno setter -
entries
→ Subject<
Iterable< MapEntry< >K, V> > -
Available on Subject<
Map< , provided by the MapChecks extensionK, V> >no setter -
first
→ Subject<
T> -
Available on Subject<
Iterable< , provided by the IterableChecks extensionT> >no setter - hashCode → int
-
The hash code for this object.
no setterinherited
-
keys
→ Subject<
Iterable< K> > -
Available on Subject<
Map< , provided by the MapChecks extensionK, V> >no setter -
last
→ Subject<
T> -
Available on Subject<
Iterable< , provided by the IterableChecks extensionT> >no setter -
length
→ Subject<
int> -
Available on Subject<
Iterable< , provided by the IterableChecks extensionT> >no setter -
length
→ Subject<
int> -
Available on Subject<
Map< , provided by the MapChecks extensionK, V> >no setter -
length
→ Subject<
int> -
Available on Subject<
String> , provided by the StringChecks extensionno setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
single
→ Subject<
T> -
Available on Subject<
Iterable< , provided by the IterableChecks extensionT> >no setter -
values
→ Subject<
Iterable< V> > -
Available on Subject<
Map< , provided by the MapChecks extensionK, V> >no setter -
withQueue
→ Subject<
StreamQueue< T> > -
Available on Subject<
Wrap the stream in aStream< , provided by the WithQueueExtension extensionT> >StreamQueueto allow using checks from StreamChecks.no setter
Methods
-
any(
Condition< T> elementCondition) → void -
Available on Subject<
Expects that the iterable contains at least on element such thatIterable< , provided by the IterableChecks extensionT> >elementConditionis satisfied. -
anyOf(
Iterable< Condition< conditions) → voidT> > -
Available on Subject<
Expects that the value satisfies the expectations invoked in at least one condition fromT> , provided by the CoreChecks extensionconditions. -
anyOf(
Iterable< AsyncCondition< conditions) → Future<StreamQueue< >T> >void> -
Available on Subject<
Expects that the stream statisfies at least one condition fromStreamQueue< , provided by the StreamChecks extensionT> >conditions. -
completes(
[AsyncCondition< T> ? completionCondition]) → Future<void> -
Available on Subject<
Expects that theFuture< , provided by the FutureChecks extensionT> >Futurecompletes to a value without throwing. -
contains(
T element) → void -
Available on Subject<
Expects that the iterable containsIterable< , provided by the IterableChecks extensionT> >elementaccording to Iterable.contains. -
contains(
Pattern pattern) → void -
Available on Subject<
Expects that the value containsString> , provided by the StringChecks extensionpatternaccording to String.contains; -
containsEqualInOrder(
Iterable< T> elements) → void -
Available on Subject<
Expects that the iterable contains a value equals to each expected value fromIterable< , provided by the IterableChecks extensionT> >elementsin the given order, with any extra elements between them. -
containsInOrder(
Iterable< String> expected) → void -
Available on Subject<
Expects that theString> , provided by the StringChecks extensionStringcontains each of the sub strings in expected in the given order, with any content between them. -
containsInOrder(
Iterable< Object?> elements) → void -
Available on Subject<
Expects that the iterable contains a value matching each expected value fromIterable< , provided by the IterableChecks extensionT> >elementsin the given order, with any extra elements between them. -
containsKey(
K key) → void -
Available on Subject<
Expects that the map containsMap< , provided by the MapChecks extensionK, V> >keyaccording to Map.containsKey. -
containsKeyThat(
Condition< K> keyCondition) → void -
Available on Subject<
Expects that the map contains some key such thatMap< , provided by the MapChecks extensionK, V> >keyConditionis satisfied. -
containsMatchingInOrder(
Iterable< Condition< conditions) → voidT> > -
Available on Subject<
Expects that the iterable contains a value matching each condition inIterable< , provided by the IterableChecks extensionT> >conditionsin the given order, with any extra elements between them. -
containsValue(
V value) → void -
Available on Subject<
Expects that the map containsMap< , provided by the MapChecks extensionK, V> >valueaccording to Map.containsValue. -
containsValueThat(
Condition< V> valueCondition) → void -
Available on Subject<
Expects that the map contains some value such thatMap< , provided by the MapChecks extensionK, V> >valueConditionis satisfied. -
deepEquals(
Iterable< Object?> expected) → void -
Available on Subject<
Expects that the iterable contains elements that are deeply equal to the elements ofIterable< , provided by the IterableChecks extensionT> >expected. -
deepEquals(
Map< Object?, Object?> expected) → void -
Available on Subject<
Expects that the map contains entries that are deeply equal to the entries ofMap< , provided by the MapChecks extensionK, V> >expected. -
doesNotComplete(
) → void -
Available on Subject<
Expects that theFuture< , provided by the FutureChecks extensionT> >Futurenever completes as a value or an error. -
emits(
[AsyncCondition< T> ? emittedCondition]) → Future<void> -
Available on Subject<
Expect that theStreamQueue< , provided by the StreamChecks extensionT> >Streamemits a value without first emitting an error. -
emitsError<
E extends Object> ([AsyncCondition< E> ? errorCondition]) → Future<void> -
Available on Subject<
Expects that the stream emits an error of typeStreamQueue< , provided by the StreamChecks extensionT> >E. -
emitsThrough(
AsyncCondition< T> condition) → Future<void> -
Available on Subject<
Expects that theStreamQueue< , provided by the StreamChecks extensionT> >Streamemits any number of events before emitting an event that satisfiescondition. -
endsWith(
String other) → void -
Available on Subject<
String> , provided by the StringChecks extension -
equals(
String expected) → void -
Available on Subject<
Expects that theString> , provided by the StringChecks extensionStringcontains exactly the same code units asexpected. -
equals(
T other) → void -
Available on Subject<
Expects that the value is equal toT> , provided by the CoreChecks extensionotheraccording to operator ==. -
equalsIgnoringCase(
String expected) → void -
Available on Subject<
Expects that theString> , provided by the StringChecks extensionStringcontains the same characters asexpectedif both were lower case. -
equalsIgnoringWhitespace(
String expected) → void -
Available on Subject<
Expects that theString> , provided by the StringChecks extensionStringcontains the same content asexpected, ignoring differences in whitsepace. -
every(
Condition< T> elementCondition) → void -
Available on Subject<
Expects there are no elements in the iterable which fail to satisfyIterable< , provided by the IterableChecks extensionT> >elementCondition. -
has<
R> (R extract(T), String name) → Subject< R> -
Available on Subject<
Extracts a property of the value for further expectations.T> , provided by the CoreChecks extension -
identicalTo(
T other) → void -
Available on Subject<
Expects that the value is identical toT> , provided by the CoreChecks extensionother. -
inOrder(
Iterable< AsyncCondition< conditions) → Future<StreamQueue< >T> >void> -
Available on Subject<
Expects that the stream satisfies each condition inStreamQueue< , provided by the StreamChecks extensionT> >conditionsserially. -
isA<
R> () → Subject< R> -
Available on Subject<
Expects that the value is assignable to typeT> , provided by the CoreChecks extensionT. -
isCloseTo(
num other, num delta) → void -
Available on Subject<
Expects that the difference between this number andnum> , provided by the NumChecks extensionotheris less than or equal todelta. -
isDone(
) → Future< void> -
Available on Subject<
Expects that the stream closes without emitting any events or errors.StreamQueue< , provided by the StreamChecks extensionT> > -
isEmpty(
) → void -
Available on Subject<
Iterable< , provided by the IterableChecks extensionT> > -
isEmpty(
) → void -
Available on Subject<
Map< , provided by the MapChecks extensionK, V> > -
isEmpty(
) → void -
Available on Subject<
String> , provided by the StringChecks extension -
isFalse(
) → void -
Available on Subject<
bool> , provided by the BoolChecks extension -
isFinite(
) → void -
Available on Subject<
Expects that num.isFinite is true.num> , provided by the NumChecks extension -
isGreaterOrEqual(
T other) → void -
Available on Subject<
Expects that this value is greater than or equal toComparable< , provided by the ComparableChecks extensionT> >other. -
isGreaterThan(
T other) → void -
Available on Subject<
Expects that this value is greater thanComparable< , provided by the ComparableChecks extensionT> >other. -
isInfinite(
) → void -
Available on Subject<
Expects that num.isInfinite is true.num> , provided by the NumChecks extension -
isLessOrEqual(
T other) → void -
Available on Subject<
Expects that this value is less than or equal toComparable< , provided by the ComparableChecks extensionT> >other. -
isLessThan(
T other) → void -
Available on Subject<
Expects that this value is less thanComparable< , provided by the ComparableChecks extensionT> >other. -
isNaN(
) → void -
Available on Subject<
Expects that num.isNaN is true.num> , provided by the NumChecks extension -
isNegative(
) → void -
Available on Subject<
Expects that num.isNegative is true.num> , provided by the NumChecks extension -
isNotA<
R> () → void -
Available on Subject<
Expects that the value is not assignable to typeT> , provided by the CoreChecks extensionR. -
isNotEmpty(
) → void -
Available on Subject<
Iterable< , provided by the IterableChecks extensionT> > -
isNotEmpty(
) → void -
Available on Subject<
String> , provided by the StringChecks extension -
isNotEmpty(
) → void -
Available on Subject<
Map< , provided by the MapChecks extensionK, V> > -
isNotFinite(
) → void -
Available on Subject<
Expects that num.isFinite is false.num> , provided by the NumChecks extension -
isNotInfinite(
) → void -
Available on Subject<
Expects that num.isInfinite is false.num> , provided by the NumChecks extension -
isNotNaN(
) → void -
Available on Subject<
Expects that num.isNaN is false.num> , provided by the NumChecks extension -
isNotNegative(
) → void -
Available on Subject<
Expects that num.isNegative is false.num> , provided by the NumChecks extension -
isNotNull(
) → Subject< T> -
Available on Subject<
T?> , provided by the NullableChecks extension -
isNull(
) → void -
Available on Subject<
T?> , provided by the NullableChecks extension -
isTrue(
) → void -
Available on Subject<
bool> , provided by the BoolChecks extension -
matchesPattern(
Pattern expected) → void -
Available on Subject<
Expects that the string matches the patternString> , provided by the StringChecks extensionexpected. -
mayEmit(
AsyncCondition< T> condition) → Future<void> -
Available on Subject<
Optionally consumes an event that matchesStreamQueue< , provided by the StreamChecks extensionT> >conditionfrom the stream. -
mayEmitMultiple(
AsyncCondition< T> condition) → Future<void> -
Available on Subject<
Optionally consumes events that matchStreamQueue< , provided by the StreamChecks extensionT> >conditionfrom the stream. -
neverEmits(
AsyncCondition< T> condition) → Future<void> -
Available on Subject<
Expects that the stream closes without emitting any event that satisfiesStreamQueue< , provided by the StreamChecks extensionT> >condition. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
not(
Condition< T> condition) → void -
Available on Subject<
Check that the expectations invoked inT> , provided by the CoreChecks extensionconditionare not satisfied by this value. -
pairwiseComparesTo<
S> (List< S> expected, Condition<T> elementCondition(S), String description) → void -
Available on Subject<
Expects that the iterable contains elements that correspond by theIterable< , provided by the IterableChecks extensionT> >elementConditionexactly to each element inexpected. -
pairwiseMatches<
S> (List< S> expected, Condition<T> elementCondition(S), String description) → void -
Available on Subject<
Expects that the iterable contains elements that correspond by theIterable< , provided by the IterableChecks extensionT> >elementConditionexactly to each element inexpected. -
returnsNormally(
) → Subject< T> -
Available on Subject<
Expects that the function returns without throwing.T Function()> , provided by the FunctionChecks extension -
skip(
String message) → Subject< T> -
Available on Subject<
Mark the currently running test as skipped and return a Subject that will ignore all expectations.T> , provided by the SkipExtension extension -
startsWith(
Pattern other) → void -
Available on Subject<
String> , provided by the StringChecks extension -
throws<
E extends Object> ([AsyncCondition< E> ? errorCondition]) → Future<void> -
Available on Subject<
Expects that theFuture< , provided by the FutureChecks extensionT> >Futurecompletes as an error. -
throws<
E> () → Subject< E> -
Available on Subject<
Expects that a function throws synchronously when it is called.T Function()> , provided by the FunctionChecks extension -
toString(
) → String -
A string representation of this object.
inherited
-
unorderedEquals(
Iterable< T> expected) → void -
Available on Subject<
Expects that the iterable contains elements which equal those ofIterable< , provided by the IterableChecks extensionT> >expectedin any order. -
unorderedMatches(
Iterable< Condition< expected) → voidT> > -
Available on Subject<
Expects that the iterable contains elements which match all conditions ofIterable< , provided by the IterableChecks extensionT> >expectedin any order. -
which(
Condition< T> condition) → void -
Available on Subject<
Applies the expectations invoked inT> , provided by the CoreChecks extensionconditionto this subject.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
-
operator [](
K key) → Subject< V> -
Available on Subject<
Map< , provided by the MapChecks extensionK, V> >