1
모바일 용 유닛 또는 통합 테스트를 작성하고 있습니다. 사용자 정의 일치자를 만들 수 있습니까?Flutter unit 또는 integration 테스트를 위해 사용자 정의 일치 프로그램을 만들 수 있습니까?
모바일 용 유닛 또는 통합 테스트를 작성하고 있습니다. 사용자 정의 일치자를 만들 수 있습니까?Flutter unit 또는 integration 테스트를 위해 사용자 정의 일치 프로그램을 만들 수 있습니까?
예, 맞춤 Matcher
클래스와 맞춤 Finder
클래스를 만들 수 있습니다.
여기에 주어진 Finder
가 Card
위젯 내부의 위젯을 발견 주장이 떨림의 사용자 정의 매처 (matcher) 중 하나입니다 :
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
클래스는 떨림 프레임 워크의 일부가 아닙니다. package:mathcer
에 정의되어 있습니다. Flutter는 package:test
에서 상속됩니다. Flutter의 모든 Matcher 클래스는이 클래스의 사용자 정의 구현입니다.
플러터의 test framework에는 custom matchers과 custom finders의 많은 정보가 있습니다.
5 분 안에 "한 줄"질문을하는 것이 좋다고 생각하지 않습니다. 특히 문서가 이미 꽤 좋은 때. https://docs.flutter.io/flutter/matcher/Matcher-class.html – Darky