在运行 Flutter 集成测试时,我遇到了 FirebaseException
被 FLUTTER TEST FRAMEWORK 捕获的问题。
有没有人能帮忙理解如何忽略集成测试中的 FirebaseException
并继续执行其余部分?
我尝试了以下解决方法:
Future<void> restoreFlutterError(Future<void> Function() call) async {
FlutterError.onError = (FlutterErrorDetails data) {
if (data.exception is FirebaseException) {
return;
}
FlutterError.presentError(data);
};
}
并在testWidgets
中调用上述方法
testWidgets('test execution', (tester) async {
await restoreFlutterError(() async {
app.main();
await tester.pumpAndSettle(const Duration(seconds: 10));
});
...
...
});
但是出现以下错误!
A test overrode FlutterError.onError but either failed to return it to its original state, or had unexpected additional errors that it could not handle. Typically, this is caused by using expect() before restoring FlutterError.onError.
非常感谢任何帮助!