Annotation Interface Rollback


@Target({TYPE,METHOD}) @Retention(RUNTIME) @Documented @Inherited public @interface Rollback
@Rollback is a test annotation that is used to indicate whether a test-managed transaction should be rolled back after the test method has completed.

Consult the class-level Javadoc for TransactionalTestExecutionListener for an explanation of test-managed transactions.

When declared as a class-level annotation, @Rollback defines the default rollback semantics for all test methods within the test class hierarchy. When declared as a method-level annotation, @Rollback defines rollback semantics for the specific test method, potentially overriding class-level default commit or rollback semantics.

@Commit can be used as direct replacement for @Rollback(false).

Warning: Declaring @Commit and @Rollback on the same test method or on the same test class is unsupported and may lead to unpredictable results.

This annotation may be used as a meta-annotation to create custom composed annotations. Consult the source code for @Commit for a concrete example.

this annotation will be inherited from an enclosing test class by default. See @NestedTestConfiguration for details.

从以下版本开始:
4.0
作者:
Sam Brannen
另请参阅:
  • 可选元素概要

    可选元素
    修饰符和类型
    可选元素
    说明
    boolean
    Whether the test-managed transaction should be rolled back after the test method has completed.
  • 元素详细资料

    • value

      boolean value
      Whether the test-managed transaction should be rolled back after the test method has completed.

      If true, the transaction will be rolled back; otherwise, the transaction will be committed.

      Defaults to true.

      默认值:
      true