我可以为 Flutter 单元测试或集成测试制作自定义匹配器吗?
Can I make a custom matcher for Flutter unit or integration tests?
我正在为移动设备编写单元或集成测试。我可以制作自定义匹配器吗?
是的,您可以创建自定义 Matcher
classes and custom Finder
类。
这是 Flutter 的自定义匹配器之一,它断言给定的 Finder
找到了 Card
小部件内的小部件:
class _IsInCard extends Matcher {
const _IsInCard();
@override
bool matches(covariant Finder finder, Map<dynamic, dynamic> matchState) => _hasAncestorOfType(finder, Card);
@override
Description describe(Description description) => description.add('in card');
}
Matcher
class is not part of the Flutter framework. It is defined in package:mathcer
. Flutter inherits it from package:test
。所有 Flutter 自带的 Matcher 类 都是它的自定义实现。
Flutter的test framework has lots of custom matchers and custom finders大家可以借鉴
我正在为移动设备编写单元或集成测试。我可以制作自定义匹配器吗?
是的,您可以创建自定义 Matcher
classes and custom Finder
类。
这是 Flutter 的自定义匹配器之一,它断言给定的 Finder
找到了 Card
小部件内的小部件:
class _IsInCard extends Matcher {
const _IsInCard();
@override
bool matches(covariant Finder finder, Map<dynamic, dynamic> matchState) => _hasAncestorOfType(finder, Card);
@override
Description describe(Description description) => description.add('in card');
}
Matcher
class is not part of the Flutter framework. It is defined in package:mathcer
. Flutter inherits it from package:test
。所有 Flutter 自带的 Matcher 类 都是它的自定义实现。
Flutter的test framework has lots of custom matchers and custom finders大家可以借鉴