Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
bb5663d2
Unverified
Commit
bb5663d2
authored
Jan 27, 2019
by
Dan Field
Committed by
GitHub
Jan 27, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add docs and sample for takeException (#27140)
* Add docs and sample for takeException * fix sample
parent
45b09424
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
0 deletions
+20
-0
matchers.dart
packages/flutter_test/lib/src/matchers.dart
+7
-0
widget_tester.dart
packages/flutter_test/lib/src/widget_tester.dart
+13
-0
No files found.
packages/flutter_test/lib/src/matchers.dart
View file @
bb5663d2
...
...
@@ -155,6 +155,9 @@ const Matcher hasAGoodToStringDeep = _HasGoodToStringDeep();
///
/// This is equivalent to `throwsA(isInstanceOf<FlutterError>())`.
///
/// If you are trying to test whether a call to [WidgetTester.pumpWidget]
/// results in a [FlutterError], see [TestWidgetsFlutterBinding.takeException].
///
/// See also:
///
/// * [throwsAssertionError], to test if a function throws any [AssertionError].
...
...
@@ -166,6 +169,10 @@ final Matcher throwsFlutterError = throwsA(isFlutterError);
///
/// This is equivalent to `throwsA(isInstanceOf<AssertionError>())`.
///
/// If you are trying to test whether a call to [WidgetTester.pumpWidget]
/// results in an [AssertionError], see
/// [TestWidgetsFlutterBinding.takeException].
///
/// See also:
///
/// * [throwsFlutterError], to test if a function throws a [FlutterError].
...
...
packages/flutter_test/lib/src/widget_tester.dart
View file @
bb5663d2
...
...
@@ -225,6 +225,19 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker
/// rebuild of the tree, even if [widget] is the same as the previous call.
/// [pump] will only rebuild the widgets that have changed.
///
/// This method should not be used as the first parameter to an [expect] or
/// [expectLater] call to test that a widget throws an exception. Instead, use
/// [TestWidgetsFlutterBinding.takeException].
///
/// {@tool sample}
/// ```dart
/// testWidgets('MyWidget asserts invalid bounds', (WidgetTester tester) async {
/// await tester.pumpWidget(MyWidget(-1));
/// expect(tester.takeException(), isAssertionError); // or isNull, as appropriate.
/// });
/// ```
/// {@end-tool}
///
/// See also [LiveTestWidgetsFlutterBindingFramePolicy], which affects how
/// this method works when the test is run with `flutter run`.
Future
<
void
>
pumpWidget
(
Widget
widget
,
[
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment