question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is there any way in Database Rider to reduce duplication of @DataSet configuration properties?

See original GitHub issue

Hi, 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:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
brunnengcommented, Sep 26, 2020

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 :

@DataSet(value = "yml/empty.yml", skipCleaningFor = {"zone_code", "product_code", "product_type", "user_type"})
class BaseTest

Where empty.yml it’s just some empty dataset to avoid error during tests execution. Then, in the test class, we put

@DbUnit(mergeDataSets = true)
@DBRider
class MyTest extends BaseTest {
   @DataSet(value = "yml/test1.yml", cleanAfter = true)
   public void test1() {
     //...
   }

   @DataSet(value = "yml/test2.yml", cleanAfter = true)
   public void test2() {
     //...
   }

And that’s it - the config is no longer duplicated!

0reactions
rmpestanocommented, Sep 26, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is there any way in Database Rider to reduce duplication of ...
Seems I figured out how to do it using merging datasets. First, we need some BaseTest for all our tests with the config...
Read more >
How do you avoid having duplicate data in a database?
Go to the Design view by right-clicking the table that contains the field. · Select the field you want to have no duplicate...
Read more >
Database Rider Documentation
DataSetBuilder has an alternative syntax, similar to SQL insert into values , which may be more appropriated to datasets with few columns and...
Read more >
Manage data sources | JetBrains Rider Documentation
In the Database tool window (View | Tool Windows | Database), click the Data Source Properties icon The Data Source Properties icon ....
Read more >
Reference | Static Transit
Dataset - A complete set of files defined by this specification reference. ... 1 - Some vehicles at this stop can be boarded...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found