Class TransactionalTests

java.lang.Object
org.dalesbred.junit.TransactionalTests
All Implemented Interfaces:
org.junit.rules.TestRule

public final class TransactionalTests extends Object implements org.junit.rules.TestRule
A JUnit TestRule that can be used to run the test-methods in transactions.

To use the rule, create a database and add the following lines to your test:

 @Rule
 public final TransactionalTests transactionalTests = new TransactionalTests(db);
 
  • Constructor Details

    • TransactionalTests

      public TransactionalTests(@NotNull @NotNull org.dalesbred.Database db)
      Constructs a rule that will wrap tests in transactions and use the default rollback-policy (TransactionalTests.RollbackPolicy.ROLLBACK_ON_FAILURE) for rolling back the transaction.
    • TransactionalTests

      public TransactionalTests(@NotNull @NotNull org.dalesbred.Database db, @NotNull @NotNull TransactionalTests.RollbackPolicy rollbackPolicy)
      Constructs a rule that will wrap tests in transactions and use the specified rollback-policy for rolling back the transaction.
    • TransactionalTests

      public TransactionalTests(@NotNull @NotNull javax.inject.Provider<org.dalesbred.Database> db)
      Constructs a rule that will wrap tests in transactions and use the default rollback-policy (TransactionalTests.RollbackPolicy.ROLLBACK_ON_FAILURE) for rolling back the transaction.
    • TransactionalTests

      public TransactionalTests(@NotNull @NotNull javax.inject.Provider<org.dalesbred.Database> db, @NotNull @NotNull TransactionalTests.RollbackPolicy rollbackPolicy)
      Constructs a rule that will wrap tests in transactions and use the specified rollback-policy for rolling back the transaction.
  • Method Details

    • apply

      @NotNull public @NotNull org.junit.runners.model.Statement apply(@NotNull @NotNull org.junit.runners.model.Statement base, @NotNull @NotNull org.junit.runner.Description description)
      Specified by:
      apply in interface org.junit.rules.TestRule