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.

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
entries Subject<Iterable<MapEntry<K, V>>>

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

no setter
first Subject<T>

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

no setter
hashCode int
The hash code for this object.
no setterinherited
keys Subject<Iterable<K>>

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

no setter
last Subject<T>

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

no setter
length Subject<int>

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

no setter
length Subject<int>

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

no setter
length Subject<int>

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

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

no setter
values Subject<Iterable<V>>

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

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<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.
anyOf(Iterable<AsyncCondition<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.
completes([AsyncCondition<T>? completionCondition]) Future<void>

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

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

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

Expects that the iterable contains element according to Iterable.contains.
contains(Pattern pattern) → void

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

Expects that the value contains pattern according to String.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(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.
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.
doesNotComplete() → void

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

Expects that the Future never completes as a value or an error.
emits([AsyncCondition<T>? emittedCondition]) Future<void>

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>([AsyncCondition<E>? errorCondition]) Future<void>

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

Expects that the stream emits an error of type E.
emitsThrough(AsyncCondition<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

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.
equals(T other) → void

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

Expects that the value is equal to other according to operator ==.
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>(R extract(T), String name) 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<AsyncCondition<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>() 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.
isDone() Future<void>

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

Expects that the stream closes without emitting any events or errors.
isEmpty() → void

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

isEmpty() → void

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

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<num>, provided by the NumChecks extension

Expects that num.isFinite is true.
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.
isInfinite() → void

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

Expects that num.isInfinite is true.
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.
isNaN() → void

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

Expects that num.isNaN is true.
isNegative() → void

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

Expects that num.isNegative is true.
isNotA<R>() → void

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

Expects that the value is not assignable to type R.
isNotEmpty() → void

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

isNotEmpty() → void

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

isNotEmpty() → void

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

isNotFinite() → void

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

Expects that num.isFinite is false.
isNotInfinite() → void

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

Expects that num.isInfinite is false.
isNotNaN() → void

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

Expects that num.isNaN is false.
isNotNegative() → void

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

Expects that num.isNegative is false.
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<String>, provided by the StringChecks extension

Expects that the string matches the pattern expected.
mayEmit(AsyncCondition<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(AsyncCondition<T> condition) Future<void>

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

Optionally consumes events that match condition from the stream.
neverEmits(AsyncCondition<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.
returnsNormally() 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

throws<E extends Object>([AsyncCondition<E>? errorCondition]) Future<void>

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

Expects that the Future completes as an error.
throws<E>() Subject<E>

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

Expects that a function throws synchronously when it is called.
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