Arquillian Persistence Extension - seeding / cleaning db and annotation naming
bmajsak Feb 23, 2012 6:26 PMHi guys,
I'm struggling a bit with naming for new annotations in APE (or maybe speculating about the features too much) . Currently we have following possibilities:
- @UsingDataSet and @ShouldMatchDataSet to use on class or test level for seeding and verifying db content using data sets (JSON, YAML, XLS or XML)
- @UsingScript which is triggered before seeding db using data sets, so can be used to prepare database (e.g. turning off integrity checks, constraints)
Based on the roadmap discussion and feedback from the early adopters there is a need for additional features, namely:
define a phase when cleanup is executed (by default it's based on DBUnit DELETE_ALL operation triggered after the test as of Alpha3 - this will be changed in Alpha4 to be triggered before the test by default)
- ability to clean up database using custom script (which will result in not using aforementioned dbunit approach)
So here are the changes which I'm considering to introduce in APE Alpha4:
- Introducing @Cleanup annotation with BEFORE | AFTER or NONE values so user can decide if he wants dbunit to be executed and when
- Additionally he can define one of the strategies
- STRICT (implemented currently) - Cleans whole database content (using DELETE_ALL). Might require turning off database constraints (e.g. referential integrity).
- USED_ROWS_ONLY - Deletes only those entries which were defined in data sets.
- USED_TABLES_ONLY - Deletes only those tables which were used in data sets.
- In some cases however it might not be sufficient (i.e. there is no way to turn off referential integrity checks). For this purpose I would like to introduce @CleanupUsingScript annotation where one can define:
- scripts to be used
- phase when it should happen (BEFORE or AFTER)
However there might be also a need to run some custom scripts after test execution (for instance to turn on integrity checks back). Therefore I was thinking to rework @UsingScript annotation and introduce following two:
- @ApplyScriptBefore
- @ApplyScriptAfter
And here are my questions - do you think all those features are needed? What about the naming?
I really like phrasing Test (is) UsingDataSet and result ShouldMatchDataSet (stolen from Aslak ) and I strongly believe that should be recommended convention. However there are also exceptional cases where I want to apply custom scripts before and after test. Hence the names I came up with.
I'm aware that @CleanupUsingScript is somehow redundant because you can achieve the same this using @ApplyScript*, but on the other hand former says clearly your intent, where latter is general purpose feature.
Looking forward to your feedback!
Cheers,
Bartosz