From the course: Spring: Test-Driven Development with JUnit

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Create integration test datasets

Create integration test datasets

From the course: Spring: Test-Driven Development with JUnit

Start my 1-month free trial

Create integration test datasets

- [Instructor] We just went through a pretty trivial example of creating test setup data by instantiating an entity object, setting values in it, and using our EntityManager to persist that object into the database. Sometimes you need to simulate a fuller and more involved data scenario to thoroughly test data access code. Well, there's a framework for that. It's called DBUnit. And for our next exercise, we will introduce the use of this framework. DBUnit is a JUnit extension that helps developers manage the nontrivial task of keeping the data store in a known state before and after testing. As usual with any of our test classes, there are setup needs. And for this case, we will have to load some DBUnit specific configurations. So let's get started and see what that looks like. So in this exercise, I'm going to go into my src/test/java tree as normal. And into my data.repos package and I'm going to open up the CustomerContactRepositoryDbUnitTest. Now take a look at the setup that's…

Contents