diff --git a/dev/devicelab/pubspec.yaml b/dev/devicelab/pubspec.yaml index f262f0ed8d..a0673dc420 100644 --- a/dev/devicelab/pubspec.yaml +++ b/dev/devicelab/pubspec.yaml @@ -16,4 +16,4 @@ dependencies: dev_dependencies: # See packages/flutter_test/pubspec.yaml for why we're pinning this version. - test: 0.12.15+9 + test: 0.12.18+2 diff --git a/packages/flutter/test/animation/curves_test.dart b/packages/flutter/test/animation/curves_test.dart index ed5ae36cc7..8b133bb096 100644 --- a/packages/flutter/test/animation/curves_test.dart +++ b/packages/flutter/test/animation/curves_test.dart @@ -105,35 +105,35 @@ void main() { }); test('Invalid transform parameter should assert', () { - expect(() => const SawTooth(2).transform(-0.0001), throws); - expect(() => const SawTooth(2).transform(1.0001), throws); + expect(() => const SawTooth(2).transform(-0.0001), throwsAssertionError); + expect(() => const SawTooth(2).transform(1.0001), throwsAssertionError); - expect(() => const Interval(0.0, 1.0).transform(-0.0001), throws); - expect(() => const Interval(0.0, 1.0).transform(1.0001), throws); + expect(() => const Interval(0.0, 1.0).transform(-0.0001), throwsAssertionError); + expect(() => const Interval(0.0, 1.0).transform(1.0001), throwsAssertionError); - expect(() => const Threshold(0.5).transform(-0.0001), throws); - expect(() => const Threshold(0.5).transform(1.0001), throws); + expect(() => const Threshold(0.5).transform(-0.0001), throwsAssertionError); + expect(() => const Threshold(0.5).transform(1.0001), throwsAssertionError); - expect(() => const ElasticInCurve().transform(-0.0001), throws); - expect(() => const ElasticInCurve().transform(1.0001), throws); + expect(() => const ElasticInCurve().transform(-0.0001), throwsAssertionError); + expect(() => const ElasticInCurve().transform(1.0001), throwsAssertionError); - expect(() => const ElasticOutCurve().transform(-0.0001), throws); - expect(() => const ElasticOutCurve().transform(1.0001), throws); + expect(() => const ElasticOutCurve().transform(-0.0001), throwsAssertionError); + expect(() => const ElasticOutCurve().transform(1.0001), throwsAssertionError); - expect(() => const Cubic(0.42, 0.0, 0.58, 1.0).transform(-0.0001), throws); - expect(() => const Cubic(0.42, 0.0, 0.58, 1.0).transform(1.0001), throws); + expect(() => const Cubic(0.42, 0.0, 0.58, 1.0).transform(-0.0001), throwsAssertionError); + expect(() => const Cubic(0.42, 0.0, 0.58, 1.0).transform(1.0001), throwsAssertionError); - expect(() => Curves.decelerate.transform(-0.0001), throws); - expect(() => Curves.decelerate.transform(1.0001), throws); + expect(() => Curves.decelerate.transform(-0.0001), throwsAssertionError); + expect(() => Curves.decelerate.transform(1.0001), throwsAssertionError); - expect(() => Curves.bounceIn.transform(-0.0001), throws); - expect(() => Curves.bounceIn.transform(1.0001), throws); + expect(() => Curves.bounceIn.transform(-0.0001), throwsAssertionError); + expect(() => Curves.bounceIn.transform(1.0001), throwsAssertionError); - expect(() => Curves.bounceOut.transform(-0.0001), throws); - expect(() => Curves.bounceOut.transform(1.0001), throws); + expect(() => Curves.bounceOut.transform(-0.0001), throwsAssertionError); + expect(() => Curves.bounceOut.transform(1.0001), throwsAssertionError); - expect(() => Curves.bounceInOut.transform(-0.0001), throws); - expect(() => Curves.bounceInOut.transform(1.0001), throws); + expect(() => Curves.bounceInOut.transform(-0.0001), throwsAssertionError); + expect(() => Curves.bounceInOut.transform(1.0001), throwsAssertionError); }); } diff --git a/packages/flutter/test/foundation/covariant_templates_test.dart b/packages/flutter/test/foundation/covariant_templates_test.dart index a5f77e5917..885adbf935 100644 --- a/packages/flutter/test/foundation/covariant_templates_test.dart +++ b/packages/flutter/test/foundation/covariant_templates_test.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'package:test/test.dart'; +import 'package:flutter_test/flutter_test.dart'; class X {} @@ -18,6 +18,6 @@ void main() { A ayAsAx = ay; expect(() { ayAsAx.u = new X(); - }, throws); + }, throwsAssertionError); }); } diff --git a/packages/flutter/test/painting/text_style_test.dart b/packages/flutter/test/painting/text_style_test.dart index 9ae396c438..dc7f488755 100644 --- a/packages/flutter/test/painting/text_style_test.dart +++ b/packages/flutter/test/painting/text_style_test.dart @@ -14,7 +14,7 @@ void main() { fontWeight: FontWeight.w800, height: 123.0, ); - expect(() { s1.fontFamily = 'test'; }, throws); // ignore: ASSIGNMENT_TO_FINAL + expect(() { s1.fontFamily = 'test'; }, throwsA(isNoSuchMethodError)); // ignore: ASSIGNMENT_TO_FINAL expect(s1.fontFamily, isNull); expect(s1.fontSize, 10.0); expect(s1.fontWeight, FontWeight.w800); diff --git a/packages/flutter/test/scheduler/debug_test.dart b/packages/flutter/test/scheduler/debug_test.dart index 697af800ff..aa8e4a5fd0 100644 --- a/packages/flutter/test/scheduler/debug_test.dart +++ b/packages/flutter/test/scheduler/debug_test.dart @@ -3,31 +3,31 @@ // found in the LICENSE file. import 'package:flutter/scheduler.dart'; -import 'package:test/test.dart'; +import 'package:flutter_test/flutter_test.dart'; void main() { test('debugAssertAllSchedulerVarsUnset control test', () { expect(() { debugAssertAllSchedulerVarsUnset('Example test'); - }, isNot(throws)); + }, isNot(throwsFlutterError)); debugPrintBeginFrameBanner = true; expect(() { debugAssertAllSchedulerVarsUnset('Example test'); - }, throws); + }, throwsFlutterError); debugPrintBeginFrameBanner = false; debugPrintEndFrameBanner = true; expect(() { debugAssertAllSchedulerVarsUnset('Example test'); - }, throws); + }, throwsFlutterError); debugPrintEndFrameBanner = false; expect(() { debugAssertAllSchedulerVarsUnset('Example test'); - }, isNot(throws)); + }, isNot(throwsFlutterError)); }); } diff --git a/packages/flutter/test/widgets/notification_test.dart b/packages/flutter/test/widgets/notification_test.dart index 12be099d50..3e153e888d 100644 --- a/packages/flutter/test/widgets/notification_test.dart +++ b/packages/flutter/test/widgets/notification_test.dart @@ -66,6 +66,6 @@ void main() { onNotification: (MyNotification value) { }, child: new Container(key: key), )); - expect(() { new MyNotification().dispatch(key.currentContext); }, throwsA(const isInstanceOf())); + expect(() { new MyNotification().dispatch(key.currentContext); }, throwsAssertionError); }); } diff --git a/packages/flutter/test/widgets/scroll_controller_test.dart b/packages/flutter/test/widgets/scroll_controller_test.dart index 9f091b9051..1533abd7a3 100644 --- a/packages/flutter/test/widgets/scroll_controller_test.dart +++ b/packages/flutter/test/widgets/scroll_controller_test.dart @@ -76,12 +76,12 @@ void main() { }).toList() )); - expect(() => controller.offset, throws); + expect(() => controller.offset, throwsAssertionError); expect(controller2.offset, equals(653.0)); expect(realOffset(), equals(controller2.offset)); - expect(() => controller.jumpTo(120.0), throws); - expect(() => controller.animateTo(132.0, duration: const Duration(milliseconds: 300), curve: Curves.ease), throws); + expect(() => controller.jumpTo(120.0), throwsAssertionError); + expect(() => controller.animateTo(132.0, duration: const Duration(milliseconds: 300), curve: Curves.ease), throwsAssertionError); await tester.pumpWidget(new ListView( key: const Key('second'), diff --git a/packages/flutter/test/widgets/set_state_4_test.dart b/packages/flutter/test/widgets/set_state_4_test.dart index 84a2816529..88b4819160 100644 --- a/packages/flutter/test/widgets/set_state_4_test.dart +++ b/packages/flutter/test/widgets/set_state_4_test.dart @@ -23,8 +23,8 @@ void main() { testWidgets('setState() catches being used with an async callback', (WidgetTester tester) async { await tester.pumpWidget(new Changer()); ChangerState s = tester.state(find.byType(Changer)); - expect(s.test0, isNot(throws)); - expect(s.test1, isNot(throws)); - expect(s.test2, throws); + expect(s.test0, isNot(throwsFlutterError)); + expect(s.test1, isNot(throwsFlutterError)); + expect(s.test2, throwsFlutterError); }); } diff --git a/packages/flutter_driver/pubspec.yaml b/packages/flutter_driver/pubspec.yaml index 7d3babd9f6..b43ccbe1b6 100644 --- a/packages/flutter_driver/pubspec.yaml +++ b/packages/flutter_driver/pubspec.yaml @@ -20,6 +20,6 @@ dependencies: sdk: flutter dev_dependencies: - test: 0.12.15+9 + test: 0.12.18+2 mockito: ^1.0.0 quiver: ^0.24.0 diff --git a/packages/flutter_test/lib/src/matchers.dart b/packages/flutter_test/lib/src/matchers.dart index 1ca742f35a..9b48366825 100644 --- a/packages/flutter_test/lib/src/matchers.dart +++ b/packages/flutter_test/lib/src/matchers.dart @@ -67,11 +67,17 @@ const Matcher isNotInCard = const _IsNotInCard(); const Matcher hasOneLineDescription = const _HasOneLineDescription(); /// A matcher for functions that throw [FlutterError]. -const Matcher throwsFlutterError = const Throws(isFlutterError); +Matcher throwsFlutterError = throwsA(isFlutterError); + +/// A matcher for functions that throw [AssertionError]. +Matcher throwsAssertionError = throwsA(isAssertionError); /// A matcher for [FlutterError]. const Matcher isFlutterError = const isInstanceOf(); +/// A matcher for [AssertionError]. +const Matcher isAssertionError = const isInstanceOf(); + /// Asserts that two [double]s are equal, within some tolerated error. /// /// Two values are considered equal if the difference between them is within diff --git a/packages/flutter_test/lib/src/widget_tester.dart b/packages/flutter_test/lib/src/widget_tester.dart index de1bf075cf..1c7a823934 100644 --- a/packages/flutter_test/lib/src/widget_tester.dart +++ b/packages/flutter_test/lib/src/widget_tester.dart @@ -120,10 +120,9 @@ Future benchmarkWidgets(WidgetTesterCallback callback) { void expect(dynamic actual, dynamic matcher, { String reason, bool verbose: false, - dynamic formatter }) { TestAsyncUtils.guardSync(); - test_package.expect(actual, matcher, reason: reason, verbose: verbose, formatter: formatter); + test_package.expect(actual, matcher, reason: reason, verbose: verbose); } /// Assert that `actual` matches `matcher`. @@ -138,9 +137,8 @@ void expect(dynamic actual, dynamic matcher, { void expectSync(dynamic actual, dynamic matcher, { String reason, bool verbose: false, - dynamic formatter }) { - test_package.expect(actual, matcher, reason: reason, verbose: verbose, formatter: formatter); + test_package.expect(actual, matcher, reason: reason, verbose: verbose); } /// Class that programmatically interacts with widgets and the test environment. diff --git a/packages/flutter_test/pubspec.yaml b/packages/flutter_test/pubspec.yaml index 69a666e7c3..4d5e7e1ae8 100644 --- a/packages/flutter_test/pubspec.yaml +++ b/packages/flutter_test/pubspec.yaml @@ -5,7 +5,7 @@ dependencies: # The flutter tools depend on very specific internal implementation # details of the 'test' package, which change between versions, so # here we pin it precisely to avoid version skew across our packages. - test: 0.12.15+9 + test: 0.12.18+2 flutter: sdk: flutter diff --git a/packages/flutter_tools/pubspec.yaml b/packages/flutter_tools/pubspec.yaml index 4909a8ef9a..d16ced8802 100644 --- a/packages/flutter_tools/pubspec.yaml +++ b/packages/flutter_tools/pubspec.yaml @@ -34,7 +34,7 @@ dependencies: # We depend on very specific internal implementation details of the # 'test' package, which change between versions, so here we pin it # precisely. - test: 0.12.15+9 + test: 0.12.18+2 # Version from the vended Dart SDK as defined in `dependency_overrides`. analyzer: any diff --git a/packages/flutter_tools/test/drive_test.dart b/packages/flutter_tools/test/drive_test.dart index 05bbe681b9..0acef186d4 100644 --- a/packages/flutter_tools/test/drive_test.dart +++ b/packages/flutter_tools/test/drive_test.dart @@ -88,7 +88,7 @@ void main() { testUsingContext('returns 1 when app fails to run', () async { withMockDevice(); - appStarter = expectAsync((DriveCommand command) async => null); + appStarter = expectAsync1((DriveCommand command) async => null); String testApp = fs.path.join(cwd.path, 'test_driver', 'e2e.dart'); String testFile = fs.path.join(cwd.path, 'test_driver', 'e2e_test.dart'); @@ -157,14 +157,14 @@ void main() { String testApp = fs.path.join(cwd.path, 'test', 'e2e.dart'); String testFile = fs.path.join(cwd.path, 'test_driver', 'e2e_test.dart'); - appStarter = expectAsync((DriveCommand command) async { + appStarter = expectAsync1((DriveCommand command) async { return new LaunchResult.succeeded(); }); - testRunner = expectAsync((List testArgs, String observatoryUri) async { + testRunner = expectAsync2((List testArgs, String observatoryUri) async { expect(testArgs, [testFile]); return null; }); - appStopper = expectAsync((DriveCommand command) async { + appStopper = expectAsync1((DriveCommand command) async { return true; }); @@ -188,13 +188,13 @@ void main() { String testApp = fs.path.join(cwd.path, 'test', 'e2e.dart'); String testFile = fs.path.join(cwd.path, 'test_driver', 'e2e_test.dart'); - appStarter = expectAsync((DriveCommand command) async { + appStarter = expectAsync1((DriveCommand command) async { return new LaunchResult.succeeded(); }); testRunner = (List testArgs, String observatoryUri) async { throwToolExit(null, exitCode: 123); }; - appStopper = expectAsync((DriveCommand command) async { + appStopper = expectAsync1((DriveCommand command) async { return true; }); diff --git a/packages/flutter_tools/test/src/common.dart b/packages/flutter_tools/test/src/common.dart index d13fcf261e..4a4976af81 100644 --- a/packages/flutter_tools/test/src/common.dart +++ b/packages/flutter_tools/test/src/common.dart @@ -37,8 +37,8 @@ void updateFileModificationTime(String path, /// Matcher for functions that throw ToolExit. Matcher throwsToolExit([int exitCode]) { return exitCode == null - ? const Throws(isToolExit) - : new Throws(allOf(isToolExit, (ToolExit e) => e.exitCode == exitCode)); + ? throwsA(isToolExit) + : throwsA(allOf(isToolExit, (ToolExit e) => e.exitCode == exitCode)); } /// Matcher for [ToolExit]s.