repositories {
maven {
url "http://dl.bintray.com/fint/maven"
}
}
testCompile('no.fint:fint-model-test-utils:1.2.0')The fint-model-test-utils is created to be used with the Spock framework.
The library will generate json files for the model and the relation names.
When new model classes are generated these can be matched against the persisted json files.
- The setup method initializes the JsonSnapshots. It will scan the package that the test class is in (when sending in
this) and find all model classes. It is also possible to send in a String containing the package name, if the test class and the model classes are not in the same package. - The
create snapshotstest generates the json files. When calling create it will first remove all files in thesrc/test/resources/snapshotsfolder before generating new. The test is setup to only run when the system propertyCREATE_SNAPSHOTSis set. The return value from create is a boolean indicating if the snapshot file generation has succeeded. - The
matches snapshotstest will match the snapshots and relation names for all model classes.
class ModelSpec extends Specification {
private JsonSnapshots jsonSnapshots
void setup() {
jsonSnapshots = new JsonSnapshots(this) // or new JsonSnapshots('no.fint.model')
}
@Requires({ Boolean.valueOf(sys['CREATE_SNAPSHOTS']) })
def "Create snapshots"() {
expect:
jsonSnapshots.create()
}
def "Matches snapshots"() {
expect:
jsonSnapshots.matchesSnapshots()
jsonSnapshots.matchesRelationNames()
}
}