install method Null safety

void install(
  1. {bool restartForEachTest = false}
)

Installs this handler to automatically start before tests begin running,

Registers the startup and teardown of this application as setUpAll and tearDownAll test callbacks. Invoke this method at the top of your test's main function.

    void main() {
      final harness = TestHarness<MyApp>()..install();

      test("...", () { ... });
    }

Pass true for the optional argument restartForEachTest to startup and teardown the application between each test.

Implementation

void install({bool restartForEachTest = false}) {
  if (restartForEachTest) {
    setUp(() async {
      await start();
    });

    tearDown(() async {
      await stop();
    });
  } else {
    setUpAll(() async {
      await start();
    });

    tearDownAll(() async {
      await stop();
    });
  }

  setUp(onSetUp);
  tearDown(onTearDown);
}