Annotation Interface MicronautTest


@Retention(RUNTIME) @Target({METHOD,ANNOTATION_TYPE,TYPE}) @Factory @Inherited @Requires(condition=TestActiveCondition.class) public @interface MicronautTest
Annotation that can be applied to any Spock spec or JUnit 5 test to make it a Micronaut test.
Since:
2.1.0
Author:
graemerocher, Álvaro Sánchez-Mariscal
  • Element Details

    • application

      Class<?> application
      Returns:
      The application class of the application
      Default:
      void.class
    • environments

      String[] environments
      Returns:
      The environments to use.
      Default:
      {}
    • packages

      String[] packages
      Returns:
      The packages to consider for scanning.
      Default:
      {}
    • propertySources

      String[] propertySources
      One or many references to classpath. For example: "classpath:mytest.yml"
      Returns:
      The property sources
      Default:
      {}
    • rollback

      boolean rollback
      Whether to rollback (if possible) any data access code between each test execution.
      Returns:
      True if changes should be rolled back
      Default:
      true
    • transactional

      boolean transactional
      Allow disabling or enabling of automatic transaction wrapping.
      Returns:
      Whether to wrap a test in a transaction.
      Default:
      true
    • rebuildContext

      boolean rebuildContext
      Whether to rebuild the application context before each test method. The first test uses the context started for the class, which is built before the class's own setup runs, unless that test declares method-level @Property values.
      Returns:
      true if the application context should be rebuilt for each test method
      Default:
      false
    • contextBuilder

      Class<? extends io.micronaut.context.ApplicationContextBuilder>[] contextBuilder
      The application context builder to use to construct the context.
      Returns:
      The builder
      Default:
      {}
    • transactionMode

      TransactionMode transactionMode
      The transaction mode describing how transactions should be handled for each test.
      Returns:
      The transaction mode
      Default:
      SEPARATE_TRANSACTIONS
    • startApplication

      boolean startApplication

      Whether to start EmbeddedApplication.

      When false, only the application context will be started. This can be used to disable EmbeddedServer.

      Returns:
      true if EmbeddedApplication should be started
      Default:
      true
    • deduceEnvironment

      boolean deduceEnvironment
      Controls whether Micronaut should deduce additional active environments.
      Returns:
      false to mimic setting MICRONAUT_ENV_DEDUCTION=false
      Default:
      true