Extension for Specs2
Need to create Database
instance, which will be used in specs
import specs2x.Database
val database = new Database {
def start() {
// setup database
}
def withSession[T](f: => T) = {
// create session
f
// submit session
}
def stop() {
// clean and stop database
}
}
Then pass database instance to the specification
import specs2x.DatabaseSpec
class ExampleDatabaseSpec extends DatabaseSpec(database) {
"ExampleDatabase" should {
"insert record" in success // each will be called in separate session
"read record" in success // also DatabaseSpec is sequential by default
"delete record" in success // if any will fail, we will not go further (sequential ^ stopOnFail)
}
}
- Add this repository to your pom.xml:
<repository>
<id>thenewmotion</id>
<name>The New Motion Repository</name>
<url>http://nexus.thenewmotion.com/content/repositories/releases-public</url>
</repository>
- Add dependency to your pom.xml:
<dependency>
<groupId>ua.t3hnar.specs2x</groupId>
<artifactId>specs2x_2.9.2</artifactId>
<version>1.0</version>
</dependency>