declareTest function

void declareTest(
  1. String name,
  2. List<Component> components,
  3. FutureOr<void> body(), {
  4. Timeout? timeout,
  5. Object? skip,
  6. Map<String, dynamic> config = const {},
})

Implementation

void declareTest(
  String name,
  List<Component> components,
  FutureOr<void> Function() body, {
  dart_test.Timeout? timeout,
  Object? skip,
  Map<String, dynamic> config = const {},
}) {
  dart_test.group(name, () {
    TestHost? host;
    dart_test.setUp(() async {
      host = TestHost(
        components: components,
        initialConfig: config,
        testBody: body,
      );
      await host?.initialize();
    });

    dart_test.test(
      name,
      () async => await host!
          .findComponent(Find<_TestRunnerServiceInstance>(), null)
          .runTest(body),
      timeout: timeout,
      skip: skip,
    );

    dart_test.tearDown(() async {
      if (host?.state == ServiceHostState.initialized) {
        await host?.shutdown();
      }
    });
  });
}