Class AnnotatedTestOptIn

java.lang.Object
org.dbunit.annotation.runtime.AnnotatedTestOptIn

public class AnnotatedTestOptIn extends Object
Decides whether a test opts into the org.dbunit.annotation family, and so into the annotation-driven lifecycle: any of the annotations that configure a test (DbUnitConfig, DbUnitPrep, DbUnitSetup, DbUnitExpected, DbUnitTearDown, DbUnitRowCountCheck) on the test method or class, or a @DbUnitTester/@DbUnitTestCase field in the test class or one enclosing it. A plain, unannotated IDatabaseTester field alone is not an opt-in - that is the 3.5.0 lifecycle-only style, left exactly as it was.

A binding passes its own AnnotationLookup and the test classes in scope, and may add opt-ins of its own, such as DbUnitExtension's @DbUnitTest. The binding decides what an opted-out test gets: DbUnitExtension keeps its 3.5.0 lifecycle for it, while the Spring listener leaves it entirely alone.

Public so a binding outside org.dbunit.annotation.runtime - such as DbUnitExtension or a Spring TestExecutionListener - can reach it too.

Since:
3.6.0
Author:
Jeff Jensen
  • Method Details

    • isOptedIn

      public static boolean isOptedIn(AnnotationLookup lookup, Collection<Class<?>> testClasses)
      Returns whether the test opts into the org.dbunit.annotation family.
      Parameters:
      lookup - Finds the annotations that apply to the test.
      testClasses - The test class and every class enclosing it whose fields count, for @Nested support.
      Returns:
      true when the test carries an annotation that configures it, or a class in scope declares a @DbUnitTester or @DbUnitTestCase field.