Instrument pending timers in tests (#37646)
Flutter widget tests assert if a test completes with timers still pending. However, it can be hard to diagnose where a pending timer came from. For example, a widget might consume a third-party library that internally uses a timer. I added a FakeAsync.pendingTimersDebugInfo getter to quiver (https://github.com/google/quiver-dart/pull/500). Make flutter_test use it. Additionally modify Flutter's debugPrintStack to take an optional StackTrace argument instead of always printing StackTrace.current. Fixes #4237.
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
// Copyright 2018 The Chromium 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';
|
||||
|
||||
void main() {
|
||||
failingPendingTimerTest();
|
||||
}
|
||||
|
||||
void failingPendingTimerTest() {
|
||||
testWidgets('flutter_test pending timer - negative', (WidgetTester tester) async {
|
||||
Timer(const Duration(minutes: 10), () {});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user