jonataslaw / get_storage

A fast, extra light and synchronous key-value storage to Get framework
MIT License
369 stars 83 forks source link

await GetStorage.init() hangs inside an integration test #86

Open dinvlad opened 2 years ago

dinvlad commented 2 years ago

Hi folks,

I'm trying to test a main() function called from inside an integration test, however it seems to hang the test indefinitely:

// main.dart
import 'package:get_storage/get_storage.dart';

Future<void> main() async {
  await GetStorage.init();
  // runApp(AppWidget());
}
// main_test.dart
import 'package:flutter_test/flutter_test.dart';
import './main.dart' as app;

void main() {
  testWidgets('app loads', (WidgetTester tester) async {
    await app.main();
  }
}

The same thing happens if I put await GetStorage.init(); directly inside testWidgets(), but not if I put it into setUpAll(() async { }) block, as in all of the examples. However, I'd like to keep await GetStorage.init(); inside the main() function of the app, in order to test it successfully. What makes it hang unless I put it into setUpAll()? And is there any workaround for this?

Thanks

SagarZadafiya commented 2 years ago

same issue i faced