Is there any way in Database Rider to reduce duplication of @DataSet configuration properties?
See original GitHub issueHi, is there any way in Database Rider to reduce duplication of DataSet configuration properties?
For example, suppose we have:
@DataSet(value = "yml/test1.yml", cleanAfter = true, skipCleaningFor = {"zone_code", "product_code", "product_type", "user_type"})
public void test1() {
//...
}
@DataSet(value = "yml/test2.yml", cleanAfter = true, skipCleaningFor = {"zone_code", "product_code", "product_type", "user_type"})
public void test2() {
//...
}
Here as you can see cleanAfter and skipCleaningFor are duplicated. And this is just an example. The list of skipCleaningFor can be even longer. Having hundreds of tests with the same list of skipped tables is a nightmare. Imagine we need to change this list in hundreds of places.
Extracting this list to some static final variable is not an option, because parameters to annotation can be only true inline constants (you will get compilation error).
Meta datasets are one of the ways of reducing duplication but they include ALL properties, and it’s not possible to override some of the properties (like the value in my example)
Merge datasets looks promising, but not sure…
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
Seems I figured out how to do it using merging datasets. First, we need some BaseTest for all our tests with the config of skipCleaningFor :
Where empty.yml it’s just some empty dataset to avoid error during tests execution. Then, in the test class, we put
And that’s it - the config is no longer duplicated!
I see, for that you either use as on your first comment or just don’t use cleanBefore/After and don’t declare the tables.