use throwsA (#82238)

This commit is contained in:
Alexandre Ardhuin
2021-05-11 19:19:01 +02:00
committed by GitHub
parent 7b9a175557
commit df3662b15e
22 changed files with 311 additions and 297 deletions

View File

@@ -24,14 +24,15 @@ void main() {
return processRunner.runProcess(commandLine);
})(<String>['this_executable_better_not_exist_2857632534321']),
throwsA(isA<PreparePackageException>()));
try {
await processRunner.runProcess(<String>['this_executable_better_not_exist_2857632534321']);
} on PreparePackageException catch (e) {
expect(
e.message,
await expectLater(
() => processRunner.runProcess(<String>['this_executable_better_not_exist_2857632534321']),
throwsA(isA<PreparePackageException>().having(
(PreparePackageException error) => error.message,
'message',
contains('ProcessException: Failed to find "this_executable_better_not_exist_2857632534321" in the search path'),
);
}
)),
);
});
for (final String platformName in <String>['macos', 'linux', 'windows']) {
final FakePlatform platform = FakePlatform(

View File

@@ -26,12 +26,14 @@ void main() {
});
test('waitForAbsent should time out waiting for text "present" to disappear', () async {
try {
await driver.waitForAbsent(presentText, timeout: const Duration(seconds: 1));
fail('expected DriverError');
} on DriverError catch (error) {
expect(error.message, contains('Timeout while executing waitForAbsent'));
}
await expectLater(
() => driver.waitForAbsent(presentText, timeout: const Duration(seconds: 1)),
throwsA(isA<DriverError>().having(
(DriverError error) => error.message,
'message',
contains('Timeout while executing waitForAbsent'),
)),
);
});
test('waitForAbsent should resolve when text "present" disappears', () async {
@@ -51,12 +53,14 @@ void main() {
});
test('waitFor times out waiting for "present" to reappear', () async {
try {
await driver.waitFor(presentText, timeout: const Duration(seconds: 1));
fail('expected DriverError');
} on DriverError catch (error) {
expect(error.message, contains('Timeout while executing waitFor'));
}
await expectLater(
() => driver.waitFor(presentText, timeout: const Duration(seconds: 1)),
throwsA(isA<DriverError>().having(
(DriverError error) => error.message,
'message',
contains('Timeout while executing waitFor'),
)),
);
});
test('waitFor should resolve when text "present" reappears', () async {