initializer property

The initializer of the slice, for springBootTest(initializers:): it replaces the databases and leaves out the beans, in each context the test starts.

It also adds the data starter's auto-configuration when the application lacks it. The generator puts the auto-configuration of every dependency into an application, so an application that lists the starter has it; the application of the starter's own tests (which is not a dependency of itself) does not.

Implementation

ApplicationContextInitializer get initializer =>
    ApplicationContextInitializer.of((context) {
      if (replaceDatabase) {
        TestDatabase(
          hasSqliteDriver: TestDatabase.hasSqliteDriverIn(
            DataTestSlice.applicationDefinitions(_modules),
          ),
        ).initialize(context);
      }
      if (!_autoConfigurations.any(
        (module) =>
            module.name == springBootStarterDataAutoConfiguration.name,
      )) {
        context.register(springBootStarterDataAutoConfiguration);
      }
      context.addBeanFactoryPostProcessor(
        DataTestSlice(_modules, include: include),
      );
    });