spring-framework / org.springframework.test.context.transaction / TestTransaction

TestTransaction

open class TestTransaction

TestTransaction provides a collection of static utility methods for programmatic interaction with test-managed transactions within test methods, before methods, and after methods.

Consult the javadocs for TransactionalTestExecutionListener for a detailed explanation of test-managed transactions.

Support for TestTransaction is automatically available whenever the TransactionalTestExecutionListener is enabled. Note that the TransactionalTestExecutionListener is typically enabled by default, but it can also be manually enabled via the TestExecutionListeners annotation.

Author
Sam Brannen

Since
4.1

See Also
TransactionalTestExecutionListener

Constructors

<init>

TestTransaction()

TestTransaction provides a collection of static utility methods for programmatic interaction with test-managed transactions within test methods, before methods, and after methods.

Consult the javadocs for TransactionalTestExecutionListener for a detailed explanation of test-managed transactions.

Support for TestTransaction is automatically available whenever the TransactionalTestExecutionListener is enabled. Note that the TransactionalTestExecutionListener is typically enabled by default, but it can also be manually enabled via the TestExecutionListeners annotation.

Functions

end

open static fun end(): Unit

Immediately force a commit or rollback of the current test-managed transaction, according to the rollback flag.

flagForCommit

open static fun flagForCommit(): Unit

Flag the current test-managed transaction for commit.

Invoking this method will not end the current transaction. Rather, the value of this flag will be used to determine whether or not the current test-managed transaction should be rolled back or committed once it is ended.

flagForRollback

open static fun flagForRollback(): Unit

Flag the current test-managed transaction for rollback.

Invoking this method will not end the current transaction. Rather, the value of this flag will be used to determine whether or not the current test-managed transaction should be rolled back or committed once it is ended.

isActive

open static fun isActive(): Boolean

Determine whether a test-managed transaction is currently active.

isFlaggedForRollback

open static fun isFlaggedForRollback(): Boolean

Determine whether the current test-managed transaction has been flagged for rollback or flagged for commit.

start

open static fun start(): Unit

Start a new test-managed transaction.

Only call this method if #end has been called or if no transaction has been previously started.