We have test fixtures using a loan template . Use this template to create the “seed data" needed to run a test. when the test is data dependent. after
"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- a test devices return data subject, dataSource, formTyperespectively, from the database. withDataSourceRequired subjectimplicitly. To build DefinitionModelrequires datasource.idand formtype.id. therefore, depending on the data requirements of the test that causes such data construction devices, many nested conditions of attachment are created. Is there a better way to “compose” / structure such fixtures?
source
share