use throwsXxx instead of throwsA(isA<Xxx>()) (#82328)
diff --git a/packages/flutter/test/cupertino/bottom_tab_bar_test.dart b/packages/flutter/test/cupertino/bottom_tab_bar_test.dart
index a7dc8b8..6bd33d4 100644
--- a/packages/flutter/test/cupertino/bottom_tab_bar_test.dart
+++ b/packages/flutter/test/cupertino/bottom_tab_bar_test.dart
@@ -39,7 +39,7 @@
),
],
)),
- throwsA(isA<AssertionError>().having(
+ throwsA(isAssertionError.having(
(AssertionError error) => error.toString(),
'.toString()',
contains('items.length'),
diff --git a/packages/flutter/test/cupertino/segmented_control_test.dart b/packages/flutter/test/cupertino/segmented_control_test.dart
index d68a34c..7defd4e 100644
--- a/packages/flutter/test/cupertino/segmented_control_test.dart
+++ b/packages/flutter/test/cupertino/segmented_control_test.dart
@@ -94,7 +94,7 @@
),
),
),
- throwsA(isA<AssertionError>().having(
+ throwsA(isAssertionError.having(
(AssertionError error) => error.toString(),
'.toString()',
contains('children.length'),
@@ -110,7 +110,7 @@
),
),
),
- throwsA(isA<AssertionError>().having(
+ throwsA(isAssertionError.having(
(AssertionError error) => error.toString(),
'.toString()',
contains('children.length'),
@@ -220,7 +220,7 @@
),
),
),
- throwsA(isA<AssertionError>().having(
+ throwsA(isAssertionError.having(
(AssertionError error) => error.toString(),
'.toString()',
contains('children'),
diff --git a/packages/flutter/test/cupertino/sliding_segmented_control_test.dart b/packages/flutter/test/cupertino/sliding_segmented_control_test.dart
index eca9f7a..f48a463 100644
--- a/packages/flutter/test/cupertino/sliding_segmented_control_test.dart
+++ b/packages/flutter/test/cupertino/sliding_segmented_control_test.dart
@@ -82,7 +82,7 @@
onValueChanged: defaultCallback,
),
),
- throwsA(isA<AssertionError>().having(
+ throwsA(isAssertionError.having(
(AssertionError error) => error.toString(),
'.toString()',
contains('children.length'),
@@ -97,7 +97,7 @@
onValueChanged: defaultCallback,
),
),
- throwsA(isA<AssertionError>().having(
+ throwsA(isAssertionError.having(
(AssertionError error) => error.toString(),
'.toString()',
contains('children.length'),
@@ -117,7 +117,7 @@
onValueChanged: defaultCallback,
),
),
- throwsA(isA<AssertionError>().having(
+ throwsA(isAssertionError.having(
(AssertionError error) => error.toString(),
'.toString()',
contains('groupValue must be either null or one of the keys in the children map'),
diff --git a/packages/flutter/test/material/dropdown_form_field_test.dart b/packages/flutter/test/material/dropdown_form_field_test.dart
index b1f5d27..66883d6 100644
--- a/packages/flutter/test/material/dropdown_form_field_test.dart
+++ b/packages/flutter/test/material/dropdown_form_field_test.dart
@@ -588,7 +588,7 @@
),
),
),
- throwsA(isA<AssertionError>().having(
+ throwsA(isAssertionError.having(
(AssertionError error) => error.toString(),
'.toString()',
contains("There should be exactly one item with [DropdownButton]'s value"),
@@ -617,7 +617,7 @@
),
),
),
- throwsA(isA<AssertionError>().having(
+ throwsA(isAssertionError.having(
(AssertionError error) => error.toString(),
'.toString()',
contains("There should be exactly one item with [DropdownButton]'s value"),
diff --git a/packages/flutter/test/material/dropdown_test.dart b/packages/flutter/test/material/dropdown_test.dart
index c9d7d0a..e502918 100644
--- a/packages/flutter/test/material/dropdown_test.dart
+++ b/packages/flutter/test/material/dropdown_test.dart
@@ -457,7 +457,7 @@
),
),
),
- throwsA(isA<AssertionError>().having(
+ throwsA(isAssertionError.having(
(AssertionError error) => error.toString(),
'.toString()',
contains("There should be exactly one item with [DropdownButton]'s value"),
@@ -486,7 +486,7 @@
),
),
),
- throwsA(isA<AssertionError>().having(
+ throwsA(isAssertionError.having(
(AssertionError error) => error.toString(),
'.toString()',
contains("There should be exactly one item with [DropdownButton]'s value"),
diff --git a/packages/flutter/test/material/toggle_buttons_test.dart b/packages/flutter/test/material/toggle_buttons_test.dart
index 7bfe290..b4eeefe 100644
--- a/packages/flutter/test/material/toggle_buttons_test.dart
+++ b/packages/flutter/test/material/toggle_buttons_test.dart
@@ -185,7 +185,7 @@
),
),
),
- throwsA(isA<AssertionError>().having(
+ throwsA(isAssertionError.having(
(AssertionError error) => error.toString(),
'.toString()',
allOf(
diff --git a/packages/flutter/test/rendering/box_test.dart b/packages/flutter/test/rendering/box_test.dart
index 8737c99..358aad7 100644
--- a/packages/flutter/test/rendering/box_test.dart
+++ b/packages/flutter/test/rendering/box_test.dart
@@ -980,7 +980,7 @@
},
);
},
- throwsA(isA<AssertionError>().having(
+ throwsA(isAssertionError.having(
(AssertionError error) => error.message,
'message',
'paintTransform must be invertible.',
@@ -996,7 +996,7 @@
},
);
},
- throwsA(isA<AssertionError>().having(
+ throwsA(isAssertionError.having(
(AssertionError error) => error.message,
'message',
'Exactly one transform or offset argument must be provided.',
diff --git a/packages/flutter/test/services/restoration_bucket_test.dart b/packages/flutter/test/services/restoration_bucket_test.dart
index 1f5c7bb..4652ce9 100644
--- a/packages/flutter/test/services/restoration_bucket_test.dart
+++ b/packages/flutter/test/services/restoration_bucket_test.dart
@@ -183,7 +183,7 @@
// child1 is not given up before running finalizers.
expect(
() => manager.doSerialization(),
- throwsA(isA<FlutterError>().having(
+ throwsA(isFlutterError.having(
(FlutterError error) => error.message,
'message',
equals(
diff --git a/packages/flutter/test/widgets/grid_view_test.dart b/packages/flutter/test/widgets/grid_view_test.dart
index e777308..c0f87cd 100644
--- a/packages/flutter/test/widgets/grid_view_test.dart
+++ b/packages/flutter/test/widgets/grid_view_test.dart
@@ -768,7 +768,7 @@
child: GridView.extent(
maxCrossAxisExtent: maxCrossAxisExtent,
),
- ), throwsA(isA<AssertionError>()));
+ ), throwsAssertionError);
});
}
diff --git a/packages/flutter/test/widgets/list_wheel_scroll_view_test.dart b/packages/flutter/test/widgets/list_wheel_scroll_view_test.dart
index f1b8fea..46ac0c9 100644
--- a/packages/flutter/test/widgets/list_wheel_scroll_view_test.dart
+++ b/packages/flutter/test/widgets/list_wheel_scroll_view_test.dart
@@ -56,7 +56,7 @@
itemExtent: 20.0,
children: const <Widget>[],
),
- throwsA(isA<AssertionError>().having(
+ throwsA(isAssertionError.having(
(AssertionError error) => error.message,
'message',
contains("You can't set a diameterRatio of 0"),
diff --git a/packages/flutter/test/widgets/page_view_test.dart b/packages/flutter/test/widgets/page_view_test.dart
index 9973b8d..c5daa57 100644
--- a/packages/flutter/test/widgets/page_view_test.dart
+++ b/packages/flutter/test/widgets/page_view_test.dart
@@ -758,7 +758,7 @@
final PageController controller = PageController();
expect(
() => controller.page,
- throwsA(isA<AssertionError>().having(
+ throwsA(isAssertionError.having(
(AssertionError error) => error.message,
'message',
equals('PageController.page cannot be accessed before a PageView is built with it.'),
@@ -792,7 +792,7 @@
);
expect(
() => controller.page,
- throwsA(isA<AssertionError>().having(
+ throwsA(isAssertionError.having(
(AssertionError error) => error.message,
'message',
equals('PageController.page cannot be accessed before a PageView is built with it.'),
diff --git a/packages/flutter_driver/test/src/real_tests/flutter_driver_test.dart b/packages/flutter_driver/test/src/real_tests/flutter_driver_test.dart
index 2c08073..b3928e0 100644
--- a/packages/flutter_driver/test/src/real_tests/flutter_driver_test.dart
+++ b/packages/flutter_driver/test/src/real_tests/flutter_driver_test.dart
@@ -632,11 +632,11 @@
group('VMServiceFlutterDriver Unsupported error', () {
test('enableAccessibility', () async {
- expect(driver.enableAccessibility(), throwsA(isA<UnsupportedError>()));
+ expect(driver.enableAccessibility(), throwsUnsupportedError);
});
test('webDriver', () async {
- expect(() => driver.webDriver, throwsA(isA<UnsupportedError>()));
+ expect(() => driver.webDriver, throwsUnsupportedError);
});
});
});
@@ -913,28 +913,23 @@
group('WebFlutterDriver Unimplemented/Unsupported error', () {
test('forceGC', () async {
- expect(driver.forceGC(),
- throwsA(isA<UnimplementedError>()));
+ expect(driver.forceGC(), throwsUnimplementedError);
});
test('getVmFlags', () async {
- expect(driver.getVmFlags(),
- throwsA(isA<UnimplementedError>()));
+ expect(driver.getVmFlags(), throwsUnimplementedError);
});
test('waitUntilFirstFrameRasterized', () async {
- expect(driver.waitUntilFirstFrameRasterized(),
- throwsA(isA<UnimplementedError>()));
+ expect(driver.waitUntilFirstFrameRasterized(), throwsUnimplementedError);
});
test('appIsoloate', () async {
- expect(() => driver.appIsolate.extensionRPCs,
- throwsA(isA<UnsupportedError>()));
+ expect(() => driver.appIsolate.extensionRPCs, throwsUnsupportedError);
});
test('serviceClient', () async {
- expect(() => driver.serviceClient.getVM(),
- throwsA(isA<UnsupportedError>()));
+ expect(() => driver.serviceClient.getVM(), throwsUnsupportedError);
});
});
});
@@ -949,14 +944,10 @@
});
test('tracing', () async {
- expect(driver.traceAction(() async { return Future<dynamic>.value(); }),
- throwsA(isA<UnsupportedError>()));
- expect(driver.startTracing(),
- throwsA(isA<UnsupportedError>()));
- expect(driver.stopTracingAndDownloadTimeline(),
- throwsA(isA<UnsupportedError>()));
- expect(driver.clearTimeline(),
- throwsA(isA<UnsupportedError>()));
+ expect(driver.traceAction(() async { return Future<dynamic>.value(); }), throwsUnsupportedError);
+ expect(driver.startTracing(), throwsUnsupportedError);
+ expect(driver.stopTracingAndDownloadTimeline(), throwsUnsupportedError);
+ expect(driver.clearTimeline(), throwsUnsupportedError);
});
});
}
diff --git a/packages/flutter_driver/test/src/real_tests/io_extension_test.dart b/packages/flutter_driver/test/src/real_tests/io_extension_test.dart
index 2e4c663..e61e34f 100644
--- a/packages/flutter_driver/test/src/real_tests/io_extension_test.dart
+++ b/packages/flutter_driver/test/src/real_tests/io_extension_test.dart
@@ -17,8 +17,7 @@
});
test('io_extension should throw exception', () {
- expect(() => registerWebServiceExtension(call),
- throwsA(isA<UnsupportedError>()));
+ expect(() => registerWebServiceExtension(call), throwsUnsupportedError);
});
});
}
diff --git a/packages/flutter_test/test/goldens_test.dart b/packages/flutter_test/test/goldens_test.dart
index 411e69f..74f2f94 100644
--- a/packages/flutter_test/test/goldens_test.dart
+++ b/packages/flutter_test/test/goldens_test.dart
@@ -185,7 +185,7 @@
await fs.file(fix('/golden.png')).writeAsBytes(_kColorFailurePngBytes);
await expectLater(
() => doComparison(),
- throwsA(isA<FlutterError>().having(
+ throwsA(isFlutterError.having(
(FlutterError error) => error.message,
'message',
contains('% diff detected'),
@@ -216,7 +216,7 @@
..writeAsBytesSync(_kColorFailurePngBytes);
await expectLater(
() => doComparison('subdir/golden.png'),
- throwsA(isA<FlutterError>().having(
+ throwsA(isFlutterError.having(
(FlutterError error) => error.message,
'message',
contains('% diff detected'),
@@ -255,7 +255,7 @@
await fs.file(fix('/golden.png')).writeAsBytes(_kSizeFailurePngBytes);
await expectLater(
() => doComparison(),
- throwsA(isA<FlutterError>().having(
+ throwsA(isFlutterError.having(
(FlutterError error) => error.message,
'message',
contains('image sizes do not match'),
@@ -267,7 +267,7 @@
await fs.file(fix('/golden.png')).writeAsBytes(_kColorFailurePngBytes);
await expectLater(
() => doComparison(),
- throwsA(isA<FlutterError>().having(
+ throwsA(isFlutterError.having(
(FlutterError error) => error.message,
'message',
contains('% diff detected'),
@@ -279,7 +279,7 @@
await fs.file(fix('/golden.png')).writeAsBytes(<int>[]);
await expectLater(
() => doComparison(),
- throwsA(isA<FlutterError>().having(
+ throwsA(isFlutterError.having(
(FlutterError error) => error.message,
'message',
contains('null image provided'),
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/build_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/build_test.dart
index ed9e11b..d168ab2 100644
--- a/packages/flutter_tools/test/commands.shard/hermetic/build_test.dart
+++ b/packages/flutter_tools/test/commands.shard/hermetic/build_test.dart
@@ -5,9 +5,9 @@
// @dart = 2.8
import 'package:args/command_runner.dart';
-import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/runner/flutter_command.dart';
+import '../../src/common.dart';
import '../../src/context.dart';
import '../../src/test_flutter_command_runner.dart';
@@ -19,7 +19,7 @@
expect(() => commandRunner.run(<String>[
'build',
'--obfuscate',
- ]), throwsA(isA<ToolExit>()));
+ ]), throwsToolExit());
});
}
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/generate_localizations_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/generate_localizations_test.dart
index 05e804d..6deed87 100644
--- a/packages/flutter_tools/test/commands.shard/hermetic/generate_localizations_test.dart
+++ b/packages/flutter_tools/test/commands.shard/hermetic/generate_localizations_test.dart
@@ -5,13 +5,13 @@
// @dart = 2.8
import 'package:file/memory.dart';
-import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/commands/generate_localizations.dart';
import 'package:flutter_tools/src/runner/flutter_command.dart';
import '../../integration.shard/test_data/basic_project.dart';
+import '../../src/common.dart';
import '../../src/context.dart';
import '../../src/test_flutter_command_runner.dart';
@@ -100,7 +100,7 @@
'--header="some header',
'--header-file="header.txt"',
]),
- throwsA(isA<ToolExit>()),
+ throwsToolExit(),
);
});
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/run_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/run_test.dart
index 5854c81..1ed9d54 100644
--- a/packages/flutter_tools/test/commands.shard/hermetic/run_test.dart
+++ b/packages/flutter_tools/test/commands.shard/hermetic/run_test.dart
@@ -75,7 +75,7 @@
'--no-pub',
'--show-test-device',
]),
- throwsA(isA<Exception>().having(
+ throwsA(isException.having(
(Exception exception) => exception.toString(),
'toString',
isNot(contains('--fast-start is not supported with --use-application-binary')),
@@ -102,7 +102,7 @@
'run',
'--no-pub',
]),
- throwsA(isA<ToolExit>()),
+ throwsToolExit(),
);
final BufferLogger bufferLogger = globals.logger as BufferLogger;
expect(
@@ -127,11 +127,7 @@
'run',
'--no-pub',
]),
- throwsA(isA<ToolExit>().having(
- (ToolExit error) => error.toString(),
- 'toString()',
- contains('No pubspec.yaml file found'),
- )),
+ throwsToolExit(message: 'No pubspec.yaml file found'),
);
}, overrides: <Type, Generator>{
FileSystem: () => fileSystem,
@@ -510,7 +506,7 @@
'run',
'--no-pub',
'--bundle-sksl-path=foo.json',
- ]), throwsA(isA<ToolExit>().having((ToolExit exit) => exit.message, 'message', contains('No SkSL shader bundle found at foo.json'))));
+ ]), throwsToolExit(message: 'No SkSL shader bundle found at foo.json'));
});
}
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/screenshot_command_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/screenshot_command_test.dart
index 4dd900b..2e075d4 100644
--- a/packages/flutter_tools/test/commands.shard/hermetic/screenshot_command_test.dart
+++ b/packages/flutter_tools/test/commands.shard/hermetic/screenshot_command_test.dart
@@ -30,12 +30,12 @@
await expectLater(() => createTestCommandRunner(ScreenshotCommand())
.run(<String>['screenshot', '--type=skia', '--observatory-url=http://localhost:8181']),
- throwsA(isA<Exception>().having((dynamic exception) => exception.toString(), 'message', contains('dummy'))),
+ throwsA(isException.having((Exception exception) => exception.toString(), 'message', contains('dummy'))),
);
await expectLater(() => createTestCommandRunner(ScreenshotCommand())
.run(<String>['screenshot', '--type=rasterizer', '--observatory-url=http://localhost:8181']),
- throwsA(isA<Exception>().having((dynamic exception) => exception.toString(), 'message', contains('dummy'))),
+ throwsA(isException.having((Exception exception) => exception.toString(), 'message', contains('dummy'))),
);
});
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/test_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/test_test.dart
index 3c05999..8ad9454 100644
--- a/packages/flutter_tools/test/commands.shard/hermetic/test_test.dart
+++ b/packages/flutter_tools/test/commands.shard/hermetic/test_test.dart
@@ -211,8 +211,7 @@
'--coverage',
'--',
'test/fake_test.dart',
- ]), throwsA(isA<ToolExit>()
- .having((ToolExit toolExit) => toolExit.message, 'message', isNull)));
+ ]), throwsA(isA<ToolExit>().having((ToolExit toolExit) => toolExit.message, 'message', isNull)));
}, overrides: <Type, Generator>{
FileSystem: () => fs,
ProcessManager: () => FakeProcessManager.any(),
diff --git a/packages/flutter_tools/test/general.shard/android/android_device_port_forwarder_test.dart b/packages/flutter_tools/test/general.shard/android/android_device_port_forwarder_test.dart
index ae66ad7..7210c6f 100644
--- a/packages/flutter_tools/test/general.shard/android/android_device_port_forwarder_test.dart
+++ b/packages/flutter_tools/test/general.shard/android/android_device_port_forwarder_test.dart
@@ -5,7 +5,6 @@
// @dart = 2.8
import 'package:flutter_tools/src/android/android_device.dart';
-import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/device_port_forwarder.dart';
@@ -78,7 +77,7 @@
logger: BufferLogger.test(),
);
- expect(forwarder.forward(123, hostPort: 456), throwsA(isA<ProcessException>()));
+ expect(forwarder.forward(123, hostPort: 456), throwsProcessException());
});
testWithoutContext('AndroidDevicePortForwarder forwardedPorts returns empty '
@@ -159,6 +158,6 @@
logger: BufferLogger.test(),
);
- expect(() => forwarder.unforward(ForwardedPort(456, 23)), throwsA(isA<ProcessException>()));
+ expect(() => forwarder.unforward(ForwardedPort(456, 23)), throwsProcessException());
});
}
diff --git a/packages/flutter_tools/test/general.shard/android/android_gradle_builder_test.dart b/packages/flutter_tools/test/general.shard/android/android_gradle_builder_test.dart
index f8f7170..03f6525 100644
--- a/packages/flutter_tools/test/general.shard/android/android_gradle_builder_test.dart
+++ b/packages/flutter_tools/test/general.shard/android/android_gradle_builder_test.dart
@@ -358,7 +358,7 @@
..writeAsStringSync('apply from: irrelevant/flutter.gradle');
await expectLater(() async {
- await builder.buildGradleApp(
+ await builder.buildGradleApp(
project: FlutterProject.fromDirectoryTest(fileSystem.currentDirectory),
androidBuildInfo: const AndroidBuildInfo(
BuildInfo(
@@ -371,8 +371,7 @@
isBuildingBundle: false,
localGradleErrors: const <GradleHandledError>[],
);
- },
- throwsA(isA<ProcessException>()));
+ }, throwsProcessException());
expect(processManager, hasNoRemainingExpectations);
});
diff --git a/packages/flutter_tools/test/general.shard/artifact_updater_test.dart b/packages/flutter_tools/test/general.shard/artifact_updater_test.dart
index 14f64df..6a3f56d 100644
--- a/packages/flutter_tools/test/general.shard/artifact_updater_test.dart
+++ b/packages/flutter_tools/test/general.shard/artifact_updater_test.dart
@@ -4,7 +4,6 @@
import 'package:file/memory.dart';
import 'package:file_testing/file_testing.dart';
-import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/logger.dart';
@@ -288,7 +287,7 @@
'test message',
Uri.parse('http://test.zip'),
fileSystem.currentDirectory.childDirectory('out'),
- ), throwsA(isA<ArgumentError>()));
+ ), throwsArgumentError);
expect(logger.statusText, contains('test message'));
expect(fileSystem.file('out/test'), isNot(exists));
@@ -361,7 +360,7 @@
'test message',
Uri.parse('http://test.zip'),
fileSystem.currentDirectory.childDirectory('out'),
- ), throwsA(isA<ToolExit>()));
+ ), throwsToolExit());
expect(fileSystem.file('te,[/test'), isNot(exists));
expect(fileSystem.file('out/test'), isNot(exists));
});
@@ -385,7 +384,7 @@
'test message',
Uri.parse('http://test.zip'),
fileSystem.currentDirectory.childDirectory('out'),
- ), throwsA(isA<ToolExit>()));
+ ), throwsToolExit());
expect(fileSystem.file('te,[/test'), isNot(exists));
expect(fileSystem.file('out/test'), isNot(exists));
});
diff --git a/packages/flutter_tools/test/general.shard/base/common_test.dart b/packages/flutter_tools/test/general.shard/base/common_test.dart
index 0ffb6c2..6263260 100644
--- a/packages/flutter_tools/test/general.shard/base/common_test.dart
+++ b/packages/flutter_tools/test/general.shard/base/common_test.dart
@@ -26,7 +26,7 @@
});
testWithoutContext('Throws if accessing the Zone', () {
- expect(() => context.get<Object>(), throwsA(isA<UnsupportedError>()));
+ expect(() => context.get<Object>(), throwsUnsupportedError);
});
});
}
diff --git a/packages/flutter_tools/test/general.shard/base/error_handling_io_test.dart b/packages/flutter_tools/test/general.shard/base/error_handling_io_test.dart
index 62b8112..25769af 100644
--- a/packages/flutter_tools/test/general.shard/base/error_handling_io_test.dart
+++ b/packages/flutter_tools/test/general.shard/base/error_handling_io_test.dart
@@ -168,7 +168,7 @@
when(file.deleteSync(recursive: false))
.thenThrow(const FileSystemException('', '', OSError('', 2)));
- expect(() => ErrorHandlingFileSystem.deleteIfExists(file), throwsA(isA<ToolExit>()));
+ expect(() => ErrorHandlingFileSystem.deleteIfExists(file), throwsToolExit());
});
testWithoutContext('deleteIfExists does not tool exit if file exists on read-only '
@@ -182,7 +182,7 @@
ErrorHandlingFileSystem.noExitOnFailure(() {
ErrorHandlingFileSystem.deleteIfExists(file);
});
- }, throwsA(isA<FileSystemException>()));
+ }, throwsFileSystemException());
});
group('throws ToolExit on Windows', () {
@@ -213,7 +213,7 @@
final File file = fs.file('file');
expect(() => ErrorHandlingFileSystem.noExitOnFailure(
- () => file.writeAsStringSync('')), throwsA(isA<Exception>()));
+ () => file.writeAsStringSync('')), throwsException);
// nesting does not unconditionally re-enable errors.
expect(() {
@@ -221,10 +221,10 @@
ErrorHandlingFileSystem.noExitOnFailure(() { });
file.writeAsStringSync('');
});
- }, throwsA(isA<Exception>()));
+ }, throwsException);
// Check that state does not leak.
- expect(() => file.writeAsStringSync(''), throwsA(isA<ToolExit>()));
+ expect(() => file.writeAsStringSync(''), throwsToolExit());
});
testWithoutContext('when access is denied', () async {
diff --git a/packages/flutter_tools/test/general.shard/base/logger_test.dart b/packages/flutter_tools/test/general.shard/base/logger_test.dart
index e117b8b..f11bcb9 100644
--- a/packages/flutter_tools/test/general.shard/base/logger_test.dart
+++ b/packages/flutter_tools/test/general.shard/base/logger_test.dart
@@ -227,7 +227,7 @@
expect(
() => asLogger<AppRunLogger>(notifyingLogger),
- throwsA(isA<StateError>()),
+ throwsStateError,
);
});
@@ -335,8 +335,8 @@
logger.printStatus('message');
logger.printError('error message');
- expect(() async => stdout.done, throwsA(isA<Exception>()));
- expect(() async => stderr.done, throwsA(isA<Exception>()));
+ expect(() async => stdout.done, throwsException);
+ expect(() async => stderr.done, throwsException);
});
group('Spinners', () {
diff --git a/packages/flutter_tools/test/general.shard/base/os_test.dart b/packages/flutter_tools/test/general.shard/base/os_test.dart
index 7af5b9c..2a9f27a 100644
--- a/packages/flutter_tools/test/general.shard/base/os_test.dart
+++ b/packages/flutter_tools/test/general.shard/base/os_test.dart
@@ -4,7 +4,6 @@
import 'package:file/file.dart';
import 'package:file/memory.dart';
-import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/os.dart';
@@ -100,7 +99,7 @@
processManager: fakeProcessManager,
);
- expect(() => utils.which(kExecutable), throwsA(isA<ToolExit>()));
+ expect(() => utils.which(kExecutable), throwsToolExit());
});
testWithoutContext('returns null when executable does not exist', () async {
diff --git a/packages/flutter_tools/test/general.shard/base/process_test.dart b/packages/flutter_tools/test/general.shard/base/process_test.dart
index 12fef9d..3792ae5 100644
--- a/packages/flutter_tools/test/general.shard/base/process_test.dart
+++ b/packages/flutter_tools/test/general.shard/base/process_test.dart
@@ -35,8 +35,7 @@
exitCode: 1,
));
- expect(() async => processUtils.run(<String>['false'], throwOnError: true),
- throwsA(isA<ProcessException>()));
+ expect(() async => processUtils.run(<String>['false'], throwOnError: true), throwsProcessException());
});
});
@@ -124,8 +123,7 @@
],
exitCode: 1,
));
- expect(() => processUtils.run(<String>['kaboom'], throwOnError: true),
- throwsA(isA<ProcessException>()));
+ expect(() => processUtils.run(<String>['kaboom'], throwOnError: true), throwsProcessException());
});
testWithoutContext(' does not throw on allowed Failures', () async {
@@ -158,7 +156,7 @@
throwOnError: true,
allowedFailures: (int c) => c == 1,
),
- throwsA(isA<ProcessException>()),
+ throwsProcessException(),
);
});
});
@@ -269,7 +267,8 @@
throwOnError: true,
allowedFailures: (int c) => c == 1,
),
- throwsA(isA<ProcessException>()));
+ throwsProcessException(),
+ );
});
testWithoutContext(' prints stdout and stderr to trace on success', () async {
@@ -294,8 +293,7 @@
stdout: 'stdout',
stderr: 'stderr',
));
- expect(() => processUtils.runSync(<String>['kaboom'], throwOnError: true),
- throwsA(isA<ProcessException>()));
+ expect(() => processUtils.runSync(<String>['kaboom'], throwOnError: true), throwsProcessException());
expect(testLogger.statusText, contains('stdout'));
expect(testLogger.errorText, contains('stderr'));
});
diff --git a/packages/flutter_tools/test/general.shard/build_system/targets/assets_test.dart b/packages/flutter_tools/test/general.shard/build_system/targets/assets_test.dart
index bcdba6e..77b612e 100644
--- a/packages/flutter_tools/test/general.shard/build_system/targets/assets_test.dart
+++ b/packages/flutter_tools/test/general.shard/build_system/targets/assets_test.dart
@@ -110,8 +110,7 @@
''');
- expect(() async => const CopyAssets().build(environment),
- throwsA(isA<Exception>()));
+ expect(() async => const CopyAssets().build(environment), throwsException);
}, overrides: <Type, Generator>{
FileSystem: () => fileSystem,
ProcessManager: () => FakeProcessManager.any(),
@@ -138,7 +137,7 @@
fileSystem: MemoryFileSystem.test(),
logger: BufferLogger.test(),
engineVersion: null,
- ), throwsA(isA<Exception>()));
+ ), throwsException);
});
testWithoutContext('processSkSLBundle throws exception if the bundle is not '
@@ -154,7 +153,7 @@
fileSystem: fileSystem,
logger: logger,
engineVersion: null,
- ), throwsA(isA<Exception>()));
+ ), throwsException);
expect(logger.errorText, contains('was not a JSON object'));
});
@@ -171,7 +170,7 @@
fileSystem: fileSystem,
logger: logger,
engineVersion: null,
- ), throwsA(isA<Exception>()));
+ ), throwsException);
expect(logger.errorText, contains('was not a JSON object'));
});
@@ -192,7 +191,7 @@
fileSystem: fileSystem,
logger: logger,
engineVersion: '2',
- ), throwsA(isA<Exception>()));
+ ), throwsException);
expect(logger.errorText, contains('Expected Flutter 1, but found 2'));
});
diff --git a/packages/flutter_tools/test/general.shard/build_system/targets/common_test.dart b/packages/flutter_tools/test/general.shard/build_system/targets/common_test.dart
index 3690800..90dde14 100644
--- a/packages/flutter_tools/test/general.shard/build_system/targets/common_test.dart
+++ b/packages/flutter_tools/test/general.shard/build_system/targets/common_test.dart
@@ -104,8 +104,7 @@
], exitCode: 1),
]);
- await expectLater(() => const KernelSnapshot().build(androidEnvironment),
- throwsA(isA<Exception>()));
+ await expectLater(() => const KernelSnapshot().build(androidEnvironment), throwsException);
expect(processManager, hasNoRemainingExpectations);
});
@@ -434,8 +433,7 @@
});
testUsingContext('AotAssemblyProfile throws error if built for non-iOS platform', () async {
- expect(const AotAssemblyProfile().build(androidEnvironment),
- throwsA(isA<Exception>()));
+ expect(const AotAssemblyProfile().build(androidEnvironment), throwsException);
}, overrides: <Type, Generator>{
Platform: () => macPlatform,
FileSystem: () => fileSystem,
diff --git a/packages/flutter_tools/test/general.shard/build_system/targets/desktop_test.dart b/packages/flutter_tools/test/general.shard/build_system/targets/desktop_test.dart
index 11c3d10..f83abfa 100644
--- a/packages/flutter_tools/test/general.shard/build_system/targets/desktop_test.dart
+++ b/packages/flutter_tools/test/general.shard/build_system/targets/desktop_test.dart
@@ -64,7 +64,7 @@
'a.txt',
],
clientSourcePaths: <String>['foo'],
- ), throwsA(isA<Exception>()));
+ ), throwsException);
});
testWithoutContext('unpackDesktopArtifacts throws when attempting to copy missing directory', () async {
@@ -79,7 +79,7 @@
'a.txt',
],
clientSourcePaths: <String>['foo'],
- ), throwsA(isA<Exception>()));
+ ), throwsException);
});
testWithoutContext('unpackDesktopArtifacts does not require a client source path', () async {
diff --git a/packages/flutter_tools/test/general.shard/build_system/targets/ios_test.dart b/packages/flutter_tools/test/general.shard/build_system/targets/ios_test.dart
index dd69acf..f26bc09 100644
--- a/packages/flutter_tools/test/general.shard/build_system/targets/ios_test.dart
+++ b/packages/flutter_tools/test/general.shard/build_system/targets/ios_test.dart
@@ -225,7 +225,7 @@
fileSystem: fileSystem,
);
- expect(const AotAssemblyRelease().build(environment), throwsA(isA<Exception>()
+ expect(const AotAssemblyRelease().build(environment), throwsA(isException
.having(
(Exception exception) => exception.toString(),
'description',
@@ -254,13 +254,11 @@
environment.defines[kBuildMode] = 'release';
environment.defines[kIosArchs] = 'x86_64';
- expect(const AotAssemblyRelease().build(environment), throwsA(isA<Exception>()
- .having(
- (Exception exception) => exception.toString(),
+ expect(const AotAssemblyRelease().build(environment), throwsA(isException.having(
+ (Exception exception) => exception.toString(),
'description',
contains('required define SdkRoot but it was not provided'),
- )
- ));
+ )));
expect(processManager.hasRemainingExpectations, isFalse);
}, overrides: <Type, Generator>{
FileSystem: () => fileSystem,
@@ -371,7 +369,7 @@
processManager.addCommand(copyPhysicalFrameworkCommand);
await expectLater(
const DebugUnpackIOS().build(environment),
- throwsA(isA<Exception>().having(
+ throwsA(isException.having(
(Exception exception) => exception.toString(),
'description',
contains('Flutter.framework/Flutter does not exist, cannot thin'),
@@ -412,12 +410,13 @@
]);
await expectLater(
- const DebugUnpackIOS().build(environment),
- throwsA(isA<Exception>().having(
- (Exception exception) => exception.toString(),
- 'description',
- contains('does not contain arm64 armv7. Running lipo -info:\nArchitectures in the fat file:'),
- )));
+ const DebugUnpackIOS().build(environment),
+ throwsA(isException.having(
+ (Exception exception) => exception.toString(),
+ 'description',
+ contains('does not contain arm64 armv7. Running lipo -info:\nArchitectures in the fat file:'),
+ )),
+ );
});
testWithoutContext('fails when lipo extract fails', () async {
@@ -466,11 +465,12 @@
await expectLater(
const DebugUnpackIOS().build(environment),
- throwsA(isA<Exception>().having(
- (Exception exception) => exception.toString(),
+ throwsA(isException.having(
+ (Exception exception) => exception.toString(),
'description',
contains('Failed to extract arm64 armv7 for output/Flutter.framework/Flutter.\nlipo error\nRunning lipo -info:\nArchitectures in the fat file:'),
- )));
+ )),
+ );
});
testWithoutContext('skips thin framework', () async {
@@ -581,12 +581,13 @@
]);
await expectLater(
- const DebugUnpackIOS().build(environment),
- throwsA(isA<Exception>().having(
- (Exception exception) => exception.toString(),
- 'description',
- contains('Failed to strip bitcode for output/Flutter.framework/Flutter.\nbitcode_strip error'),
- )));
+ const DebugUnpackIOS().build(environment),
+ throwsA(isException.having(
+ (Exception exception) => exception.toString(),
+ 'description',
+ contains('Failed to strip bitcode for output/Flutter.framework/Flutter.\nbitcode_strip error'),
+ )),
+ );
expect(processManager.hasRemainingExpectations, isFalse);
});
@@ -653,12 +654,13 @@
]);
await expectLater(
- const DebugUnpackIOS().build(environment),
- throwsA(isA<Exception>().having(
- (Exception exception) => exception.toString(),
- 'description',
- contains('Failed to codesign output/Flutter.framework/Flutter with identity ABC123.\ncodesign error'),
- )));
+ const DebugUnpackIOS().build(environment),
+ throwsA(isException.having(
+ (Exception exception) => exception.toString(),
+ 'description',
+ contains('Failed to codesign output/Flutter.framework/Flutter with identity ABC123.\ncodesign error'),
+ )),
+ );
expect(processManager.hasRemainingExpectations, isFalse);
});
diff --git a/packages/flutter_tools/test/general.shard/build_system/targets/localizations_test.dart b/packages/flutter_tools/test/general.shard/build_system/targets/localizations_test.dart
index 509a55b..64e053e 100644
--- a/packages/flutter_tools/test/general.shard/build_system/targets/localizations_test.dart
+++ b/packages/flutter_tools/test/general.shard/build_system/targets/localizations_test.dart
@@ -96,7 +96,7 @@
file: configFile,
logger: BufferLogger.test(),
),
- throwsA(isA<Exception>()),
+ throwsException,
);
});
}
diff --git a/packages/flutter_tools/test/general.shard/build_system/targets/macos_test.dart b/packages/flutter_tools/test/general.shard/build_system/targets/macos_test.dart
index 8a73da9..f57c348 100644
--- a/packages/flutter_tools/test/general.shard/build_system/targets/macos_test.dart
+++ b/packages/flutter_tools/test/general.shard/build_system/targets/macos_test.dart
@@ -105,12 +105,13 @@
testUsingContext('thinning fails when framework missing', () async {
processManager.addCommand(copyFrameworkCommand);
await expectLater(
- const DebugUnpackMacOS().build(environment),
- throwsA(isA<Exception>().having(
- (Exception exception) => exception.toString(),
- 'description',
- contains('FlutterMacOS.framework/FlutterMacOS does not exist, cannot thin'),
- )));
+ const DebugUnpackMacOS().build(environment),
+ throwsA(isException.having(
+ (Exception exception) => exception.toString(),
+ 'description',
+ contains('FlutterMacOS.framework/FlutterMacOS does not exist, cannot thin'),
+ )),
+ );
}, overrides: <Type, Generator>{
FileSystem: () => fileSystem,
ProcessManager: () => processManager,
@@ -132,12 +133,13 @@
]);
await expectLater(
- const DebugUnpackMacOS().build(environment),
- throwsA(isA<Exception>().having(
- (Exception exception) => exception.toString(),
- 'description',
- contains('does not contain arm64 x86_64. Running lipo -info:\nArchitectures in the fat file:'),
- )));
+ const DebugUnpackMacOS().build(environment),
+ throwsA(isException.having(
+ (Exception exception) => exception.toString(),
+ 'description',
+ contains('does not contain arm64 x86_64. Running lipo -info:\nArchitectures in the fat file:'),
+ )),
+ );
}, overrides: <Type, Generator>{
FileSystem: () => fileSystem,
ProcessManager: () => processManager,
diff --git a/packages/flutter_tools/test/general.shard/cache_test.dart b/packages/flutter_tools/test/general.shard/cache_test.dart
index b4a34e2..67b8d03 100644
--- a/packages/flutter_tools/test/general.shard/cache_test.dart
+++ b/packages/flutter_tools/test/general.shard/cache_test.dart
@@ -290,7 +290,7 @@
);
await expectLater(
() => cache.updateAll(<DevelopmentArtifact>{null}),
- throwsA(isA<Exception>()),
+ throwsException,
);
verify(artifact1.update(any, any, any, any));
// Don't continue when retrieval fails.
diff --git a/packages/flutter_tools/test/general.shard/device_test.dart b/packages/flutter_tools/test/general.shard/device_test.dart
index 8b88523..5c67089 100644
--- a/packages/flutter_tools/test/general.shard/device_test.dart
+++ b/packages/flutter_tools/test/general.shard/device_test.dart
@@ -7,7 +7,6 @@
import 'dart:async';
import 'package:fake_async/fake_async.dart';
-import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/terminal.dart';
@@ -336,7 +335,7 @@
);
await expectLater(
() async => deviceManager.findTargetDevices(FakeFlutterProject()),
- throwsA(isA<ToolExit>())
+ throwsToolExit(),
);
});
diff --git a/packages/flutter_tools/test/general.shard/ios/devices_test.dart b/packages/flutter_tools/test/general.shard/ios/devices_test.dart
index 7d81aa1..1da6dff 100644
--- a/packages/flutter_tools/test/general.shard/ios/devices_test.dart
+++ b/packages/flutter_tools/test/general.shard/ios/devices_test.dart
@@ -516,8 +516,8 @@
);
when(mockXcdevice.isInstalled).thenReturn(false);
expect(
- () async { await iosDevices.pollingGetDevices(); },
- throwsA(isA<UnsupportedError>()),
+ () async { await iosDevices.pollingGetDevices(); },
+ throwsUnsupportedError,
);
});
}
diff --git a/packages/flutter_tools/test/general.shard/mdns_discovery_test.dart b/packages/flutter_tools/test/general.shard/mdns_discovery_test.dart
index 104bec9..36af829 100644
--- a/packages/flutter_tools/test/general.shard/mdns_discovery_test.dart
+++ b/packages/flutter_tools/test/general.shard/mdns_discovery_test.dart
@@ -214,7 +214,7 @@
);
expect(
() async => portDiscovery.query(),
- throwsA(isA<Exception>()),
+ throwsException,
);
});
diff --git a/packages/flutter_tools/test/general.shard/resident_web_runner_cold_test.dart b/packages/flutter_tools/test/general.shard/resident_web_runner_cold_test.dart
index df50558..85fc39f 100644
--- a/packages/flutter_tools/test/general.shard/resident_web_runner_cold_test.dart
+++ b/packages/flutter_tools/test/general.shard/resident_web_runner_cold_test.dart
@@ -114,7 +114,7 @@
usage: TestUsage(),
);
- expect(() async => residentWebRunner.run(), throwsA(isA<Exception>()));
+ expect(() async => residentWebRunner.run(), throwsException);
expect(await residentWebRunner.waitForAppToFinish(), 1);
}, overrides: <Type, Generator>{
BuildSystem: () => TestBuildSystem.error(Exception('foo')),
diff --git a/packages/flutter_tools/test/general.shard/runner/flutter_command_test.dart b/packages/flutter_tools/test/general.shard/runner/flutter_command_test.dart
index 9e16baf..1368241 100644
--- a/packages/flutter_tools/test/general.shard/runner/flutter_command_test.dart
+++ b/packages/flutter_tools/test/general.shard/runner/flutter_command_test.dart
@@ -212,7 +212,7 @@
);
await expectLater(
() => flutterCommand.run(),
- throwsA(isA<ToolExit>()),
+ throwsToolExit(),
);
expect(usage.events, <TestUsageEvent>[
const TestUsageEvent(
@@ -436,7 +436,7 @@
await expectLater(
() => flutterCommand.run(),
- throwsA(isA<ToolExit>()),
+ throwsToolExit(),
);
expect(usage.timings, contains(
const TestTimingEvent(
diff --git a/packages/flutter_tools/test/general.shard/testbed_test.dart b/packages/flutter_tools/test/general.shard/testbed_test.dart
index a69b7d8..0a15f55 100644
--- a/packages/flutter_tools/test/general.shard/testbed_test.dart
+++ b/packages/flutter_tools/test/general.shard/testbed_test.dart
@@ -96,7 +96,7 @@
ProcessUtils: () => null,
});
- expect(() => testbed.run(() {}), throwsA(isA<StateError>()));
+ expect(() => testbed.run(() {}), throwsStateError);
});
});
}