init static method
void
init()
Initialize test environment with standard setup/teardown.
Registers:
setUpAll:TestWidgetsFlutterBinding.ensureInitialized()setUp:MagicApp.reset()+Magic.flush()+Gate.flush()tearDown:Magic.flush()+Gate.flush()
Gate is a process static (facades/gate.dart) that Magic.flush()
does not clear, so without the extra call an ability defined in one
test would leak into every later test in the same file.
Implementation
static void init() {
setUpAll(() {
TestWidgetsFlutterBinding.ensureInitialized();
});
setUp(() {
MagicApp.reset();
Magic.flush();
Gate.flush();
});
tearDown(() {
Magic.flush();
Gate.flush();
// loadTranslations() installs a loader and a locale on the Translator
// singleton, which Magic.flush() does not reach; without this the next
// test formats numbers and dates in that locale without saying so.
// DateManager goes with it: it subscribes to the translator once on
// boot, so a booted DateManager outliving the disposed translator would
// stop following Lang.setLocale in every later test.
DateManager.reset();
Translator.reset();
});
}