DRY: Use JUnit @Rule Instead of Repeating Setup/@Before in Each Test

I was for a long time unhappy that DbUnit Express users have to create a @Before method in each test just to get the test database initialized. Fortunately since version 1.3.0 they don’t need to do it anymore thanks to JUnit Rules (if you are not familiar with them, they are an alternative to @Before/@After and @BeforeClass/@AfterClass, readContinue reading “DRY: Use JUnit @Rule Instead of Repeating Setup/@Before in Each Test”

DbUnit Express 1.3 is Even Easier to Use and Still Better

The DbUnit Express 1.3.0 (a thin wrapper around DbUnit to speed up DB testing) released today introduces features that make it even easier to write a DB unit test, the most interesting ones are the introduction of EmbeddedDbTesterRule which can automatically execute its onSetup thanks to JUnit’s @Rule (example) and the addition of setDataSet(fileName), which searchesContinue reading “DbUnit Express 1.3 is Even Easier to Use and Still Better”

DbUnit Express Tips: Setup Simplification, Custom Data File Convention

I’ve recently introduced here DbUnit Express, a wrapper around DbUnit intended to get you started with testing DB-related code in no time, and now I’d like to share two productivity tips: simplifying db tester setup with a parent test and implementing your own convention for data set files, for example one data set per test class.