test_api library

Classes

CustomMatcher
一个有用的实用程序类,用于通过继承实现其他匹配器. 派生类应使用功能名称和描述以及实例匹配器调用基本构造函数,并应实现featureValueOf抽象方法. [...]
Description
匹配器通过附加到Description对象来建立其错误消息. [...]
isInstanceOf<T>
DEPRECATED Use isA instead. [...]
Matcher
所有匹配器的基类. [...]
OnPlatform
用于测试套件的特定于平台的自定义的注释. [...]
Retry
用于标记要重试的注释. [...]
Skip
用于将测试套件标记为已跳过的注释.
StreamMatcher
一个匹配器,匹配来自StreamStreamQueue的事件. [...]
StringDescription
Description的默认实现. 尽管可以想象这是可以支持其他语言的地方,但这几乎不需要替换.
Tags
用于将一组用户定义的标签应用于测试套件的注释. [...]
TestFailure
测试断言失败时引发的异常.
TestOn
指示测试套件支持哪些平台的注释. [...]
Throws
请改用throwsA函数.
Timeout
表示对测试默认超时的修改的类. [...]
TypeMatcher<T>
一个Matcher子类,它支持验证目标对象的Type . [...]

Constants

anything → const Matcher
匹配任何值的匹配器.
const _IsAnything()
isArgumentError → const TypeMatcher<ArgumentError>
ArgumentError的匹配器.
const TypeMatcher<ArgumentError>()
isCastError → const TypeMatcher<CastError>
CastError的匹配器.
const TypeMatcher<CastError>()
isConcurrentModificationError → const TypeMatcher<ConcurrentModificationError>
ConcurrentModificationError的匹配器.
const TypeMatcher<ConcurrentModificationError>()
isCyclicInitializationError → const TypeMatcher<CyclicInitializationError>
CyclicInitializationError的匹配器.
const TypeMatcher<CyclicInitializationError>()
isEmpty → const Matcher
返回与isEmpty属性匹配的匹配器.
const _Empty()
isException → const TypeMatcher<Exception>
Exception的匹配器.
const TypeMatcher<Exception>()
isFalse → const Matcher
一个匹配器,匹配除布尔值true外的任何内容.
const _IsFalse()
isFormatException → const TypeMatcher<FormatException>
FormatException的匹配器.
const TypeMatcher<FormatException>()
isList → const TypeMatcher<List>
List的匹配器.
const TypeMatcher<List>()
isMap → const TypeMatcher<Map>
Map的匹配器.
const TypeMatcher<Map>()
isNaN → const Matcher
一个匹配数值NaN的匹配器.
const _IsNaN()
isNegative → const Matcher
如果match参数为负,则匹配的匹配器.
const _OrderingMatcher(0, false, true, false, 'a negative value', false)
isNonNegative → const Matcher
如果match参数为零或正数,则匹配的匹配器.
const _OrderingMatcher(0, true, false, true, 'a non-negative value', false)
isNonPositive → const Matcher
如果match参数为零或负,则匹配的匹配器.
const _OrderingMatcher(0, true, true, false, 'a non-positive value', false)
isNonZero → const Matcher
如果match参数为非零,则匹配的匹配器.
const _OrderingMatcher(0, false, true, true, 'a value not equal to')
isNoSuchMethodError → const TypeMatcher<NoSuchMethodError>
NoSuchMethodError的匹配器.
const TypeMatcher<NoSuchMethodError>()
isNotEmpty → const Matcher
返回与isNotEmpty属性匹配的匹配器.
const _NotEmpty()
isNotNaN → const Matcher
与任何非NaN值匹配的匹配器.
const _IsNotNaN()
isNotNull → const Matcher
与任何非空值匹配的匹配器.
const _IsNotNull()
isNull → const Matcher
与任何空值匹配的匹配器.
const _IsNull()
isNullThrownError → const TypeMatcher<NullThrownError>
NullThrownError的匹配器.
const TypeMatcher<NullThrownError>()
isPositive → const Matcher
A matcher which matches if the match argument is positive.
const _OrderingMatcher(0, false, false, true, 'a positive value', false)
isRangeError → const TypeMatcher<RangeError>
RangeError的匹配器.
const TypeMatcher<RangeError>()
isStateError → const TypeMatcher<StateError>
StateError的匹配器.
const TypeMatcher<StateError>()
isTrue → const Matcher
A matcher that matches the Boolean value true.
const _IsTrue()
isUnimplementedError → const TypeMatcher<UnimplementedError>
一个匹配的UnimplementedError .
const TypeMatcher<UnimplementedError>()
isUnsupportedError → const TypeMatcher<UnsupportedError>
UnsupportedError的匹配器.
const TypeMatcher<UnsupportedError>()
isZero → const Matcher
如果match参数为零,则匹配的匹配器.
const _OrderingMatcher(0, true, false, false, 'a value equal to')
returnsNormally → const Matcher
一个匹配函数的匹配器,无一例外. [...]
const _ReturnsNormally()
throws → const Matcher
不推荐使用此功能. [...]
@ 不推荐使用 ("将在0.13.0中删除")
const Throws ()
throwsArgumentError → const Matcher
引发ArgumentError的函数的匹配器.
const Throws (isArgumentError)
throwsConcurrentModificationError → const Matcher
引发ConcurrentModificationError的函数的匹配器.
const Throws (isConcurrentModificationError)
throwsCyclicInitializationError → const Matcher
引发CyclicInitializationError的函数的匹配器.
const Throws (isCyclicInitializationError)
throwsException → const Matcher
引发Exception的函数的匹配器.
const Throws (isException)
throwsFormatException → const Matcher
引发FormatException的函数的匹配器.
const Throws (isFormatException)
throwsNoSuchMethodError → const Matcher
引发NoSuchMethodError的函数的匹配器.
const Throws (isNoSuchMethodError)
throwsNullThrownError → const Matcher
引发NullThrownError的函数的匹配器.
const Throws (isNullThrownError)
throwsRangeError → const Matcher
引发RangeError的函数的匹配器.
const Throws (isRangeError)
throwsStateError → const Matcher
引发StateError的函数的匹配器.
const Throws (isStateError)
throwsUnimplementedError → const Matcher
引发Exception的函数的匹配器.
const Throws (isUnimplementedError)
throwsUnsupportedError → const Matcher
引发UnsupportedError的函数的匹配器.
const Throws (isUnsupportedError)

Properties

completes Matcher
匹配一个成功完成并带有值的未来 . [...]
最后
doesNotComplete Matcher
Matches a Future that does not complete. [...]
final
emitsDone StreamMatcher
返回一个StreamMatcher ,断言该流发出"完成"事件.
最后
neverCalled Null Function([Object, Object, Object, Object, Object, Object, Object, Object, Object, Object])
返回一个函数,如果调用该函数,它将导致测试失败. [...]
只读

Functions

addStateInfo(Map matchState, Map values) → void
嵌套匹配状态的有用工具.
addTearDown(dynamic callback()) → void
注册在当前测试后要运行的功能. [...]
allOf(dynamic arg0, [dynamic arg1, dynamic arg2, dynamic arg3, dynamic arg4, dynamic arg5, dynamic arg6]) Matcher
如果作为参数传递的所有匹配器(最多7个)匹配,则返回匹配的匹配器. [...]
anyElement(dynamic matcher) Matcher
返回与Iterable相匹配的匹配器,其中至少一个元素与给定的matcher .
anyOf(dynamic arg0, [dynamic arg1, dynamic arg2, dynamic arg3, dynamic arg4, dynamic arg5, dynamic arg6]) Matcher
如果任何给定的匹配器评估为true,则匹配. [...]
closeTo(num value, num delta) Matcher
如果match参数在某个value delta范围内,则返回匹配的匹配器. [...]
collapseWhitespace(String string) String
折叠空格的实用程序功能可运行到单个空格并去除前导/尾随空格.
completion(dynamic matcher, [String description]) Matcher
通过匹配matcher的值匹配成功完成的Future . [...]
contains(dynamic expected) Matcher
如果match参数包含期望值,则返回匹配的匹配器. [...]
containsAll(Iterable expected) Matcher
匹配Iterable ,其中包含一个元素,该元素以expected的任何顺序匹配每个值,并且可能包含其他值. [...]
containsAllInOrder(Iterable expected) Matcher
匹配Iterable ,其中包含一个元素,该元素按相同顺序按expected顺序匹配每个值,但可能包含贯穿其间的其他值. [...]
containsPair(dynamic key, dynamic value) Matcher
返回一个匹配器,该匹配器匹配包含key => value的键值对的映射.
containsValue(dynamic value) Matcher
返回一个匹配器,该匹配器匹配包含给定value地图.
emits(dynamic matcher) StreamMatcher
返回matcherStreamMatcher . [...]
emitsAnyOf(Iterable matchers) StreamMatcher
如果matchers中的至少一个匹配,则返回与流匹配的StreamMatcher . [...]
emitsError(dynamic matcher) StreamMatcher
返回与单个匹配matcher错误事件匹配的StreamMatcher .
emitsInAnyOrder(Iterable matchers) StreamMatcher
如果匹配器中的每个匹配matchers以任意顺序匹配,则返回与流匹配的StreamMatcher . [...]
emitsInOrder(Iterable matchers) StreamMatcher
Returns a StreamMatcher that matches the stream if each matcher in matchers matches, one after another. [...]
emitsThrough(dynamic matcher) StreamMatcher
返回与任意数量的事件匹配的StreamMatcher ,后跟与matcher的事件. [...]
endsWith(String suffixString) Matcher
如果match参数是一个字符串并以suffixString结尾,则返回匹配的匹配器.
equals(dynamic expected, [int limit = 100]) Matcher
如果该值在结构上等于expected ,则返回匹配的匹配器. [...]
equalsIgnoringCase(String value) Matcher
返回一个匹配器,如果match参数是一个字符串,并且不区分大小写地进行比较,则该匹配器等于value .
equalsIgnoringWhitespace(String value) Matcher
返回一个匹配器,如果match参数是一个字符串并且等于value ,则忽略空白,该匹配器将匹配. [...]
escape(String str) String
Returns str with all whitespace characters represented as their escape sequences. [...]
everyElement(dynamic matcher) Matcher
返回与Iterable相匹配的匹配器,其中所有元素都与给定的matcher .
expect(dynamic actual, dynamic matcher, {String reason, dynamic skip, bool verbose: false, ErrorFormatter formatter}) → void
断言actual匹配matcher . [...]
expectAsync(Function callback, {int count: 1, int max: 0, String id, String reason}) Function
不建议使用此功能,因为它不能在强模式下正常运行. 请改用ExpectAsync0ExpectAsync1ExpectAsync2ExpectAsync3ExpectAsync4ExpectAsync5ExpectAsync6 .
@ 不推荐使用 ("将在0.13.0中删除")
expectAsync0<T>(T callback(), {int count: 1, int max: 0, String id, String reason}) Func0<T>
通知框架,预期给定值为0的给定callback将被称为count次数(默认为1). [...]
expectAsync1<T, A>(T callback(A), {int count: 1, int max: 0, String id, String reason}) Func1<T, A>
通知框架,预期给定类型为1的给定callback将被称为count次数(默认为1). [...]
expectAsync2<T, A, B>(T callback(A, B), {int count: 1, int max: 0, String id, String reason}) Func2<T, A, B>
通知框架,预期给定类型2的给定callback将被称为count次数(默认为1). [...]
expectAsync3<T, A, B, C>(T callback(A, B, C), {int count: 1, int max: 0, String id, String reason}) Func3<T, A, B, C>
通知框架,预期给定类型3的给定callback将被称为count次数(默认为1). [...]
expectAsync4<T, A, B, C, D>(T callback(A, B, C, D), {int count: 1, int max: 0, String id, String reason}) Func4<T, A, B, C, D>
通知框架,预期给定类型为4的给定callback将被称为count次数(默认为1). [...]
expectAsync5<T, A, B, C, D, E>(T callback(A, B, C, D, E), {int count: 1, int max: 0, String id, String reason}) Func5<T, A, B, C, D, E>
通知框架,预期给定类型为5的给定callback将被调用count次(默认为1次). [...]
expectAsync6<T, A, B, C, D, E, F>(T callback(A, B, C, D, E, F), {int count: 1, int max: 0, String id, String reason}) Func6<T, A, B, C, D, E, F>
通知框架,预期给定类型为6的给定callback将被称为count次数(默认为1). [...]
expectAsyncUntil(Function callback, bool isDone(), {String id, String reason}) Function
不建议使用此功能,因为它不能在强模式下正常运行. 请改用ExpectAsyncUntil0ExpectAsyncUntil1ExpectAsyncUntil2ExpectAsyncUntil3ExpectAsyncUntil4ExpectAsyncUntil5ExpectAsyncUntil6 .
@ 不推荐使用 ("将在0.13.0中删除")
expectAsyncUntil0<T>(T callback(), bool isDone(), {String id, String reason}) Func0<T>
通知框架,预期isarone 0的给定callback将被调用,直到isDone返回true. [...]
expectAsyncUntil1<T, A>(T callback(A), bool isDone(), {String id, String reason}) Func1<T, A>
通知框架,预期isarone 1的给定callback将被调用,直到isDone返回true. [...]
expectAsyncUntil2<T, A, B>(T callback(A, B), bool isDone(), {String id, String reason}) Func2<T, A, B>
通知框架,预期isarone 2的给定callback将被调用,直到isDone返回true. [...]
expectAsyncUntil3<T, A, B, C>(T callback(A, B, C), bool isDone(), {String id, String reason}) Func3<T, A, B, C>
通知框架,预期isarone 3的给定callback将被调用,直到isDone返回true. [...]
expectAsyncUntil4<T, A, B, C, D>(T callback(A, B, C, D), bool isDone(), {String id, String reason}) Func4<T, A, B, C, D>
通知框架,预期isarone 4的给定callback将被调用,直到isDone返回true. [...]
expectAsyncUntil5<T, A, B, C, D, E>(T callback(A, B, C, D, E), bool isDone(), {String id, String reason}) Func5<T, A, B, C, D, E>
通知框架,预期isarone 5的给定callback将被调用,直到isDone返回true. [...]
expectAsyncUntil6<T, A, B, C, D, E, F>(T callback(A, B, C, D, E, F), bool isDone(), {String id, String reason}) Func6<T, A, B, C, D, E, F>
通知框架,预期isarone 6的给定callback将被调用,直到isDone返回true. [...]
expectLater(dynamic actual, dynamic matcher, {String reason, dynamic skip}) Future
就像期待 ,但返回的未来是完成时的匹配已经完成匹配. [...]
fail(String message) Null
使用提供的message抛出新的TestFailure的便捷方法.
@alwaysThrows
greaterThan(dynamic value) Matcher
如果match参数大于给定value ,则返回匹配的匹配器.
greaterThanOrEqualTo(dynamic value) Matcher
如果match参数大于或等于给定value ,则返回匹配的匹配器.
group(dynamic description, dynamic body(), {String testOn, Timeout timeout, dynamic skip, dynamic tags, Map<String, dynamic> onPlatform, int retry, bool solo: false}) → void
创建一组测试. [...]
@isTestGroup
hasLength(dynamic matcher) Matcher
如果对象的length属性与matcher匹配,则返回匹配的matcher .
inClosedOpenRange(num low, num high) Matcher
如果match参数大于或等于low且小于high ,则返回匹配的匹配器.
inExclusiveRange(num low, num high) Matcher
如果match参数大于low并且小于high ,则返回匹配的匹配器.
inInclusiveRange(num low, num high) Matcher
如果match参数大于或等于low且小于或等于high ,则返回匹配的匹配器.
inOpenClosedRange(num low, num high) Matcher
如果match参数大于low且小于等于high ,则返回匹配的匹配器.
isA<T>() TypeMatcher<T>
返回匹配类型为T对象的匹配器. [...]
isIn(dynamic expected) Matcher
如果match参数在期望值内,则返回匹配的匹配器. 这是contains的反义词.
isNot(dynamic matcher) Matcher
这将返回一个匹配器,将匹配matcher转换为其逻辑否定.
lessThan(dynamic value) Matcher
如果match参数小于给定value ,则返回匹配的匹配器.
lessThanOrEqualTo(dynamic value) Matcher
如果match参数小于或等于给定value ,则返回匹配的匹配器.
matches(dynamic re) Matcher
返回一个匹配器,如果match参数是字符串,则匹配该匹配器,并且匹配re给定的正则表达式. [...]
mayEmit(dynamic matcher) StreamMatcher
返回允许(但不要求) matcher匹配流的StreamMatcher . [...]
mayEmitMultiple(dynamic matcher) StreamMatcher
返回与匹配matcher任何数量的事件匹配的StreamMatcher . [...]
neverEmits(dynamic matcher) StreamMatcher
返回与从未匹配matcher的流匹配的StreamMatcher . [...]
orderedEquals(Iterable expected) Matcher
返回一个匹配器,该匹配器以相同的顺序匹配长度与expected元素相同的Iterable . [...]
pairwiseCompare<S, T>(Iterable<S> expected, bool comparator(S a, T b), String description) Matcher
Iterable的成对匹配器. [...]
predicate<T>(bool f(T value), [String description = 'satisfies function']) Matcher
返回一个匹配器,该匹配器使用任意函数,该函数为实际值返回true或false. [...]
printOnFailure(String message) → void
如果当前测试失败,则message . [...]
prints(dynamic matcher) Matcher
与打印与matcher文本的功能 matcher . [...]
pumpEventQueue({int times}) Future
返回一个Future ,该Future事件循环运行给定times (默认为20)后完成. [...]
registerException(dynamic error, [StackTrace stackTrace]) → void
注册为当前测试捕获的异常.
same(dynamic expected) Matcher
如果值与expected实例相同 ,则使用same来返回匹配项.
setUp(dynamic callback()) → void
注册要在测试之前运行的功能. [...]
setUpAll(dynamic callback()) → void
注册一个要在所有测试之前运行一次的功能. [...]
spawnHybridCode(String dartCode, {Object message, bool stayAlive: false}) StreamChannel
生成运行给定dartCode的VM隔离,该隔离将作为Dart库的内容加载. [...]
spawnHybridUri(dynamic uri, {Object message, bool stayAlive: false}) StreamChannel
为给定的uri生成VM隔离,它可以是UriString . [...]
startsWith(String prefixString) Matcher
返回一个匹配器,如果match参数是字符串,则匹配器以prefixString .
stringContainsInOrder(List<String> substrings) Matcher
返回匹配匹配,如果匹配参数是一个字符串,包含给定的列表substrings的相对顺序. [...]
tearDown(dynamic callback()) → void
注册要在测试后运行的功能. [...]
tearDownAll(dynamic callback()) → void
注册一个要在所有测试后运行一次的功能. [...]
test(dynamic description, dynamic body(), {String testOn, Timeout timeout, dynamic skip, dynamic tags, Map<String, dynamic> onPlatform, int retry, bool solo: false}) → void
使用给定的描述(转换为字符串)和正文创建一个新的测试用例. [...]
@isTest
throwsA(dynamic matcher) Matcher
这可以用于匹配三种对象: [...]
unorderedEquals(Iterable expected) Matcher
返回其相匹配的匹配器可迭代具有相同的长度和相同的元件为s expected ,但不一定在相同的顺序. [...]
unorderedMatches(Iterable expected) Matcher
返回一个与Iterable匹配的匹配器,其元素按expected与匹配器匹配,但顺序不一定相同. [...]
wrapMatcher(dynamic x) Matcher
接受参数并返回等效的Matcher . [...]

Typedefs

ErrorFormatter(dynamic actual, Matcher matcher, String reason, Map matchState, bool verbose) String
用于函数的类型,该函数可用于在期望失败时建立错误报告.
@ 不推荐使用 ("将从0.13.0中删除.")
Func0<T>() → T
Func1<T, A>([A a]) → T
Func2<T, A, B>([A a, B b]) → T
Func3<T, A, B, C>([A a, B b, C c]) → T
Func4<T, A, B, C, D>([A a, B b, C c, D d]) → T
Func5<T, A, B, C, D, E>([A a, B b, C c, D d, E e]) → T
Func6<T, A, B, C, D, E, F>([A a, B b, C c, D d, E e, F f]) → T