We have test fixtures using loan pattern. Leveraging this pattern to create "seed data" needed for a test to run. when test is dependent on data For e.g. following
"save definition" should {
"create a new record" in withSubject { implicit subject =>
withDataSource { implicit datasource =>
withFormType { implicit formtype =>
val definitn = DefinitionModel(-1, datasource.id, formtype.id, subject.role.id, Some(properties))
}
}
}
Where withSubject
, withDataSource
, withFormType
are test fixtures returning subject
, dataSource
, formType
data respectively from database. withDataSource
fixture requires subject
implicitly. Building DefinitionModel
requires datasource.id
and formtype.id
. so depending on the data requirement of a test calling such data builder fixtures is creating a lot of nested fixture situation. Is there a better way to "compose" /structure such fixtures?