Annotation Interface TestResourcesScope


@Retention(RUNTIME) @Target({ANNOTATION_TYPE,TYPE}) @Inherited public @interface TestResourcesScope
Defines the test resources scope to use in a test class. By default, all tests execute in the same (root) scope, which means that they share the same containers, for example.

In some cases, it may be needed to isolate a test from others, by making sure it runs with its own test resources (e.g containers).

When multiple tests are using the same scope, then the resource will be shared between those tests, and disposed whenever the last test which needed that resource has finished.

  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    The name of the strategy to use, instead of an explicit name provided with value().
    The name of the test resources scope to use.
  • Element Details

    • value

      String value
      The name of the test resources scope to use. A test can only use a single scope at once. Once the last test using this scope is executed, the scope will be automatically closed. If not set, you must provide a namingStrategy().
      Returns:
      the name of the scope
      Default:
      ""
    • namingStrategy

      Class<? extends ScopeNamingStrategy> namingStrategy
      The name of the strategy to use, instead of an explicit name provided with value().
      Returns:
      the naming strategy
      Default:
      io.micronaut.test.extensions.junit5.annotation.ScopeNamingStrategy.class