repo crud spec
RepoCrudSpec iterates over all of the persistent classes in your domain, and tests basic CRUD
operations for each of them. This includes testing
Repo.retrieve method against every
key defined in your persistent types.
RepoCrudSpecs are provided for you in the
inMemRepoCrudSpec. The latter uses an in-memory database. The former executes tests using a test
database. The database connection details are specified in the longevity
The repo crud specs are ScalaTest suites:
val spec: org.scalatest.Suite = longevityContext.repoCrudSpec
In a typical evocation of ScalaTest, for instance from within SBT, a
classpath scan is performed, and only top-level
non-abstract classes that are defined directly within a package - are
found. So to get one of these repo crud specs to run, you have to nest
it in a top-level class. For example, to run both in-memory and
against a real database:
import org.scalatest.Suites class BlogCrudSpec extends Suites( longevityContext.repoCrudSpec, longevityContext.inMemRepoCrudSpec)
ScalaTest is an optional dependency in longevity, so you’ll need to declare a dependency on ScalaTest in your own project to use the repo crud specs. Please use ScalaTest version 3.0.1 or later.
The default test data generator will not work out of the box in the face of constraint violations causing exceptions to be thrown from your persistent and embeddable constructors. In this case, you need to provide custom generators for your types. This is described in the section on enforcing constraints.