@@ -78,13 +78,29 @@ void main() {
78
78
expect (find.byKey (Key ("1-8, 2-7" )), hasNoImmediateClip); //1-5, 2-7
79
79
expect (find.byType (Tooltip ), hasOneLineDescription); //1-5, 2-8
80
80
expect (Object (), isNot (hasOneLineDescription)); //2-8
81
+
81
82
expect (
82
83
await tester.runAsync <int >(() async => testForArgumentError ()), isNull);
83
84
expect (tester.takeException (),
84
85
isArgumentError); //2-9 Captura o erro jogado pela função acima
85
- expect (false , isBrowser); //1-5, 2-10
86
86
87
- print (Tooltip (message: "q" ));
87
+ expect (true , isNot (isBrowser)); //2-10
88
+
89
+ expect (await tester.runAsync <List <String >>(() async => testForCastError ()),
90
+ isNull);
91
+ expect (tester.takeException (), isA <TypeError >()); //2-11
92
+
93
+ expect (
94
+ await tester
95
+ .runAsync <int >(() async => testForConcurrentModificationError ()),
96
+ isNull);
97
+ expect (tester.takeException (), isConcurrentModificationError); //2-12
98
+ //2-13
99
+ expect ('' , isEmpty); //2-14
100
+ expect (< int > [], isEmpty); //2-14
101
+
102
+ expect (await tester.runAsync <int >(() async => testForException ()), isNull);
103
+ expect (tester.takeException (), isException); //2-15
88
104
89
105
// Tap the '+' icon and trigger a frame.
90
106
await tester.tap (find.byIcon (Icons .add)); //1-4,
@@ -96,7 +112,18 @@ void main() {
96
112
});
97
113
}
98
114
99
- int testForArgumentError () => throw ArgumentError ();
115
+ int testForArgumentError () {
116
+ final list = < int > [1 , 2 ];
117
+ return list[2 ];
118
+ }
119
+
120
+ List <String > testForCastError () {
121
+ final list = < int > [1 , 2 ];
122
+ return list.map ((e) => e - 1 ).cast <String >();
123
+ }
124
+
125
+ int testForConcurrentModificationError () => throw ConcurrentModificationError ();
126
+ int testForException () => (1 ~ / 0 );
100
127
101
128
/*
102
129
1 - # Common Finders (ou qualquer parâmetro do tipo Finder usado acima)
@@ -135,9 +162,12 @@ int testForArgumentError() => throw ArgumentError();
135
162
Doc aqui: https://api.flutter.dev/flutter/flutter_test/hasOneLineDescription-constant.html
136
163
9 isArgumentError
137
164
10 isBrowser
138
- 11 isCastError
165
+ 11 isCastError (deprecated) -> isA<TypeError>()
139
166
12 isConcurrentModificationError
140
- 13 isCyclicInitializationError
167
+ Issue relacionada: https://github.com/flutter/flutter/issues/59601
168
+ 13 isCyclicInitializationError
169
+ Doc: https://api.flutter.dev/flutter/dart-core/CyclicInitializationError-class.html
170
+ Não achei muito sobre
141
171
14 isEmpty
142
172
15 isException
143
173
16 isFalse
0 commit comments