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.

Implementers
Available extensions

Properties

context → Context<T>

Available on Subject<T>, provided by the ContextExtension extension

The expectations and nesting context for this subject.
no setter
doesNotComplete → void

Available on Subject<Future<T>>, provided by the FutureChecks extension

Expects that the Future never completes as a value or an error.
no setter
entries → Subject<Iterable<MapEntry<K, V>>>

Available on Subject<Map<K, V>>, provided by the MapChecks extension

A Subject for the Map.entries of the map.
no setter
first → Subject<T>

Available on Subject<Iterable<T>>, provided by the IterableChecks extension

A Subject for the first element of the iterable.
no setter
hashCode → int
The hash code for this object.
no setterinherited
isDone → Future<void>

Available on Subject<StreamQueue<T>>, provided by the StreamChecks extension

Expects that the stream closes without emitting any events or errors.
no setter
isEmpty → void

Available on Subject<Iterable<T>>, provided by the IterableChecks extension

Expects that the iterable has no elements.
no setter
isEmpty → void

Available on Subject<Map<K, V>>, provided by the MapChecks extension

Expects that the map is empty.
no setter
isEmpty → void

Available on Subject<String>, provided by the StringChecks extension

Expects that the String has no characters.
no setter
isFalse → void

Available on Subject<bool>, provided by the BoolChecks extension

Expects that the value is false.
no setter
isFinite → void

Available on Subject<num>, provided by the NumChecks extension

Expects that num.isFinite is true.
no setter
isInfinite → void

Available on Subject<num>, provided by the NumChecks extension

Expects that num.isInfinite is true.
no setter
isNaN → void

Available on Subject<num>, provided by the NumChecks extension

Expects that num.isNaN is true.
no setter
isNegative → void

Available on Subject<num>, provided by the NumChecks extension

Expects that num.isNegative is true.
no setter
isNotEmpty → void

Available on Subject<Iterable<T>>, provided by the IterableChecks extension

Expects that the iterable has at least one element.
no setter
isNotEmpty → void

Available on Subject<Map<K, V>>, provided by the MapChecks extension

Expects that the map is not empty.
no setter
isNotEmpty → void

Available on Subject<String>, provided by the StringChecks extension

Expects that the String has at least one character.
no setter
isNotFinite → void

Available on Subject<num>, provided by the NumChecks extension

Expects that num.isFinite is false.
no setter
isNotInfinite → void

Available on Subject<num>, provided by the NumChecks extension

Expects that num.isInfinite is false.
no setter
isNotNaN → void

Available on Subject<num>, provided by the NumChecks extension

Expects that num.isNaN is false.
no setter
isNotNegative → void

Available on Subject<num>, provided by the NumChecks extension

Expects that num.isNegative is false.
no setter
isNull → void

Available on Subject<T?>, provided by the NullableChecks extension

Expects that the value is null.
no setter
isTrue → void

Available on Subject<bool>, provided by the BoolChecks extension

Expects that the value is true.
no setter
keys → Subject<Iterable<K>>

Available on Subject<Map<K, V>>, provided by the MapChecks extension

A Subject for the Map.keys of the map.
no setter
last → Subject<T>

Available on Subject<Iterable<T>>, provided by the IterableChecks extension

A Subject for the last element of the iterable.
no setter
length → Subject<int>

Available on Subject<Iterable<T>>, provided by the IterableChecks extension

A Subject for the number of elements in the iterable.
no setter
length → Subject<int>

Available on Subject<Map<K, V>>, provided by the MapChecks extension

A Subject for the Map.length of the map.
no setter
length → Subject<int>

Available on Subject<String>, provided by the StringChecks extension

A Subject for the number of code units in the String.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
single → Subject<T>

Available on Subject<Iterable<T>>, provided by the IterableChecks extension

A Subject for the only element of the iterable.
no setter
values → Subject<Iterable<V>>

Available on Subject<Map<K, V>>, provided by the MapChecks extension

A Subject for the Map.values of the map.
no setter
withQueue → Subject<StreamQueue<T>>

Available on Subject<Stream<T>>, provided by the WithQueueExtension extension

Wrap the stream in a StreamQueue to allow using checks from StreamChecks.
no setter

Methods

any(Condition<T> elementCondition) → void

Available on Subject<Iterable<T>>, provided by the IterableChecks extension

Expects that the iterable contains at least on element such that elementCondition is satisfied.
anyOf(Iterable<Condition<StreamQueue<T>>> conditions) → Future<void>

Available on Subject<StreamQueue<T>>, provided by the StreamChecks extension

Expects that the stream statisfies at least one condition from conditions.
anyOf(Iterable<Condition<T>> conditions) → void

Available on Subject<T>, provided by the CoreChecks extension

Expects that the value satisfies the expectations invoked in at least one condition from conditions.
completes([Condition<T>? completionCondition]) → Future<Subject<T>>

Available on Subject<Future<T>>, provided by the FutureChecks extension

Expects that the Future completes to a value without throwing.
contains(Pattern pattern) → void

Available on Subject<String>, provided by the StringChecks extension

Expects that the value contains pattern according to String.contains;
contains(T element) → void

Available on Subject<Iterable<T>>, provided by the IterableChecks extension

Expects that the iterable contains element according to Iterable.contains.
containsEqualInOrder(Iterable<T> elements) → void

Available on Subject<Iterable<T>>, provided by the IterableChecks extension

Expects that the iterable contains a value equals to each expected value from elements in the given order, with any extra elements between them.
containsInOrder(Iterable<String> expected) → void

Available on Subject<String>, provided by the StringChecks extension

Expects that the String contains each of the sub strings in expected in the given order, with any content between them.
containsInOrder(Iterable<Object?> elements) → void

Available on Subject<Iterable<T>>, provided by the IterableChecks extension

Expects that the iterable contains a value matching each expected value from elements in the given order, with any extra elements between them.
containsKey(K key) → void

Available on Subject<Map<K, V>>, provided by the MapChecks extension

Expects that the map contains key according to Map.containsKey.
containsKeyThat(Condition<K> keyCondition) → void

Available on Subject<Map<K, V>>, provided by the MapChecks extension

Expects that the map contains some key such that keyCondition is satisfied.
containsMatchingInOrder(Iterable<Condition<T>> conditions) → void

Available on Subject<Iterable<T>>, provided by the IterableChecks extension

Expects that the iterable contains a value matching each condition in conditions in the given order, with any extra elements between them.
containsValue(V value) → void

Available on Subject<Map<K, V>>, provided by the MapChecks extension

Expects that the map contains value according to Map.containsValue.
containsValueThat(Condition<V> valueCondition) → void

Available on Subject<Map<K, V>>, provided by the MapChecks extension

Expects that the map contains some value such that valueCondition is satisfied.
deepEquals(Map<Object?, Object?> expected) → void

Available on Subject<Map<K, V>>, provided by the MapChecks extension

Expects that the map contains entries that are deeply equal to the entries of expected.
deepEquals(Iterable<Object?> expected) → void

Available on Subject<Iterable<T>>, provided by the IterableChecks extension

Expects that the iterable contains elements that are deeply equal to the elements of expected.
emits([Condition<T>? emittedCondition]) → Future<Subject<T>>

Available on Subject<StreamQueue<T>>, provided by the StreamChecks extension

Expect that the Stream emits a value without first emitting an error.
emitsError<E extends Object>([Condition<E>? errorCondition]) → Future<Subject<E>>

Available on Subject<StreamQueue<T>>, provided by the StreamChecks extension

Expects that the stream emits an error of type E.
emitsThrough(Condition<T> condition) → Future<void>

Available on Subject<StreamQueue<T>>, provided by the StreamChecks extension

Expects that the Stream emits any number of events before emitting an event that satisfies condition.
endsWith(String other) → void

Available on Subject<String>, provided by the StringChecks extension

Expects that the String ends with other according to String.endsWith.
equals(T other) → void

Available on Subject<T>, provided by the CoreChecks extension

Expects that the value is equal to other according to operator ==.
equals(String expected) → void

Available on Subject<String>, provided by the StringChecks extension

Expects that the String contains exactly the same code units as expected.
equalsIgnoringCase(String expected) → void

Available on Subject<String>, provided by the StringChecks extension

Expects that the String contains the same characters as expected if both were lower case.
equalsIgnoringWhitespace(String expected) → void

Available on Subject<String>, provided by the StringChecks extension

Expects that the String contains the same content as expected, ignoring differences in whitsepace.
every(Condition<T> elementCondition) → void

Available on Subject<Iterable<T>>, provided by the IterableChecks extension

Expects there are no elements in the iterable which fail to satisfy elementCondition.
has<R>(String name, R extract(T)) → Subject<R>

Available on Subject<T>, provided by the CoreChecks extension

Extracts a property of the value for further expectations.
identicalTo(T other) → void

Available on Subject<T>, provided by the CoreChecks extension

Expects that the value is identical to other.
inOrder(Iterable<Condition<StreamQueue<T>>> conditions) → Future<void>

Available on Subject<StreamQueue<T>>, provided by the StreamChecks extension

Expects that the stream satisfies each condition in conditions serially.
isA<R>([Condition<R>? and]) → Subject<R>

Available on Subject<T>, provided by the CoreChecks extension

Expects that the value is assignable to type T.
isCloseTo(num other, num delta) → void

Available on Subject<num>, provided by the NumChecks extension

Expects that the difference between this number and other is less than or equal to delta.
isGreaterOrEqual(T other) → void

Available on Subject<Comparable<T>>, provided by the ComparableChecks extension

Expects that this value is greater than or equal to other.
isGreaterThan(T other) → void

Available on Subject<Comparable<T>>, provided by the ComparableChecks extension

Expects that this value is greater than other.
isLessOrEqual(T other) → void

Available on Subject<Comparable<T>>, provided by the ComparableChecks extension

Expects that this value is less than or equal to other.
isLessThan(T other) → void

Available on Subject<Comparable<T>>, provided by the ComparableChecks extension

Expects that this value is less than other.
isNotA<R>() → void

Available on Subject<T>, provided by the CoreChecks extension

Expects that the value is not assignable to type R.
isNotNull([Condition<T>? and]) → Subject<T>

Available on Subject<T?>, provided by the NullableChecks extension

Expects that the value is not null, and returns a Subject for the non-nullable value.
matchesPattern(Pattern expected) → void

Available on Subject<String>, provided by the StringChecks extension

Expects that the string matches the pattern expected.
mayEmit(Condition<T> condition) → Future<void>

Available on Subject<StreamQueue<T>>, provided by the StreamChecks extension

Optionally consumes an event that matches condition from the stream.
mayEmitMultiple(Condition<T> condition) → Future<void>

Available on Subject<StreamQueue<T>>, provided by the StreamChecks extension

Optionally consumes events that match condition from the stream.
neverEmits(Condition<T> condition) → Future<void>

Available on Subject<StreamQueue<T>>, provided by the StreamChecks extension

Expects that the stream closes without emitting any event that satisfies condition.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
not(Condition<T> condition) → void

Available on Subject<T>, provided by the CoreChecks extension

Check that the expectations invoked in condition are not satisfied by this value.
pairwiseComparesTo<S>(List<S> expected, Condition<T> elementCondition(S), String description) → void

Available on Subject<Iterable<T>>, provided by the IterableChecks extension

Expects that the iterable contains elements that correspond by the elementCondition exactly to each element in expected.
pairwiseMatches<S>(List<S> expected, Condition<T> elementCondition(S), String description) → void

Available on Subject<Iterable<T>>, provided by the IterableChecks extension

Expects that the iterable contains elements that correspond by the elementCondition exactly to each element in expected.
prints([Condition<String>? printCondition]) → Future<Subject<String>>

Available on Subject<Future<void> Function()>, provided by the AsyncFunctionChecks extension

Expects that the asynchronous function prints text when called and completed.
prints([Condition<String>? that]) → Subject<String>

Available on Subject<void Function()>, provided by the VoidFunctionChecks extension

Expects that the function prints text when called.
returnsNormally([Condition<T>? that]) → Subject<T>

Available on Subject<T Function()>, provided by the FunctionChecks extension

Expects that the function returns without throwing.
skip(String message) → Subject<T>

Available on Subject<T>, provided by the SkipExtension extension

Mark the currently running test as skipped and return a Subject that will ignore all expectations.
startsWith(Pattern other) → void

Available on Subject<String>, provided by the StringChecks extension

Expects that the String starts with other according to String.startsWith.
throws<E>([Condition<E>? that]) → Subject<E>

Available on Subject<T Function()>, provided by the FunctionChecks extension

Expects that a function throws synchronously when it is called.
throws<E extends Object>([Condition<E>? errorCondition]) → Future<Subject<E>>

Available on Subject<Future<T>>, provided by the FutureChecks extension

Expects that the Future completes as an error.
toString() → String
A string representation of this object.
inherited
unorderedEquals(Iterable<T> expected) → void

Available on Subject<Iterable<T>>, provided by the IterableChecks extension

Expects that the iterable contains elements which equal those of expected in any order.
unorderedMatches(Iterable<Condition<T>> expected) → void

Available on Subject<Iterable<T>>, provided by the IterableChecks extension

Expects that the iterable contains elements which match all conditions of expected in any order.
which(Condition<T> condition) → void

Available on Subject<T>, provided by the CoreChecks extension

Applies the expectations invoked in condition to this subject.

Operators

operator ==(Object other) → bool
The equality operator.
inherited
operator [](K key) → Subject<V>

Available on Subject<Map<K, V>>, provided by the MapChecks extension

A Subject for the value at key, which must be present in the map.