AutoRollback

scalikejdbc.scalatest.AutoRollback
trait AutoRollback extends LoanPattern

AutoRollback for ScalaTest

import org.scalatest.flatspec.FixtureAnyFlatSpec
class MemberSpec extends FixtureAnyFlatSpec with AutoRollback {
 describe of "Member"
 it should "create a new record" in { implicit session =>
   Member.create(1, "Alice")
   Member.find(1).isDefined should be(true)
 }
}
class LegacyAccountSpec extends FlatSpec with AutoRollback {
 override def db() = NamedDB("db2").toDB
 override def fixture(implicit session: DBSession) {
   SQL("insert into legacy_accounts values ...").update.apply()
 }

 it should "create a new record" in { implicit session =>
   LegacyAccount.create(2, "Bob")
   LegacyAccount.find(2).isDefined should be(true)
 }
}

Attributes

Source
AutoRollback.scala
Graph
Supertypes
trait LoanPattern
class Object
trait Matchable
class Any
Self type
FixtureTestSuite

Members list

Type members

Types

type FixtureParam = DBSession

Attributes

Source
AutoRollback.scala

Inherited types

type Closable = { def close(): Unit; }

Attributes

Inherited from:
LoanPattern
Source
LoanPattern.scala

Value members

Concrete methods

def db(): DB

Creates a scalikejdbc.DB instance.

Creates a scalikejdbc.DB instance.

Attributes

Returns

DB instance

Source
AutoRollback.scala
def fixture(implicit session: DBSession): Unit

Prepares database for the test.

Prepares database for the test.

Value parameters

session

db session implicitly

Attributes

Source
AutoRollback.scala
override def withFixture(test: <none>): Outcome

Provides transactional block

Provides transactional block

Value parameters

test

one arg test

Attributes

Definition Classes
Source
AutoRollback.scala

Inherited methods

def futureUsing[R <: Closable, A](resource: R)(f: R => Future[A])(implicit ec: ExecutionContext): Future[A]

Guarantees a Closeable resource will be closed after being passed to a block that takes the resource as a parameter and returns a Future.

Guarantees a Closeable resource will be closed after being passed to a block that takes the resource as a parameter and returns a Future.

Attributes

Inherited from:
LoanPattern
Source
LoanPattern.scala
def using[R <: Closable, A](resource: R)(f: R => A): A

Attributes

Inherited from:
LoanPattern
Source
LoanPattern.scala