flutter/dev/automated_tests/test_smoke_test/fail_test_on_exception_after_test.dart
Michael Goderbauer 77651bc496
Reland "Fail tests on exceptions raised after test completed (#144706)" (#144980)
Reverts flutter/flutter#144970

No changes in this PR compared to the original. The test failure was fixed by adding missing awaits in https://github.com/flutter/flutter/pull/144978.

Fixes https://github.com/flutter/flutter/issues/144353.
2024-03-12 18:17:10 +00:00

30 lines
837 B
Dart

// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'package:flutter_test/flutter_test.dart';
// This is a test to make sure that an asynchronous exception thrown after a
// test ended actually causes a test failure.
// See //flutter/dev/bots/test.dart
void main() {
final Completer<void> complete = Completer<void>();
testWidgets('test smoke test -- this test SHOULD FAIL', (WidgetTester tester) async {
tester.runAsync(() async {
Timer.run(() {
complete.complete();
throw StateError('Exception thrown after test completed.');
});
});
});
tearDown(() async {
print('Waiting for asynchronous exception...');
await complete.future;
});
}