Annotation Type EnableSilverTestEnv


@Retention(RUNTIME) @Target(TYPE) @Documented @Inherited @UnitTest @ExtendWith(SilverTestEnv.class) public @interface EnableSilverTestEnv
Enables the Silverpeas environment dedicated to the unit tests. It extends the unit test with the SilverTestEnv JUnit extension. This annotation is used to ask for an IoC/IoD subsystem to be bootstrapped for the beans eligible for management by an IoC container. The resolution of the dependencies will be then taken in charge during the execution of a unit test. This environment supports the JSR-330 annotations in business and technical codes. The IoC/IoD subsystem is implemented here by the TestBeanContainer container that provides a simple solution dedicated only to the unit tests.

In unit tests, to declare beans or mocks, required by the test, to be managed by the bean container, use respectively the annotations TestManagedBeans/ TestManagedBean and TestManagedMocks/ TestManagedMock annotations. The processing of these annotations take in charge the Named annotation: the bean will be also registered under the name given by this peculiar qualifier.

Some mocks or beans can be pre-registered into the bean container through a custom object deriving of the SilverTestEnvContext class. Such mocks and beans can then be got in the unit test either by using the ManagedBeanProvider single instance or by using the Inject annotation.

Author:
mmoquillon
See Also:
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    The test environment context to use when bootstrapping the Silverpeas unit test environment with an IoC/IoD subsystem.
  • Element Details

    • context

      Class<? extends SilverTestEnvContext> context
      The test environment context to use when bootstrapping the Silverpeas unit test environment with an IoC/IoD subsystem. This environment context provides a way to customize the behaviour of the IoC/IoD system.
      Returns:
      the test context to use for the unit test class.
      Default:
      org.silverpeas.kernel.test.extension.SilverTestEnvContext.class