Database Integration Tests – implementing it
This post is part of a series about Database Integration Tests:
Part 1: Database Integration Tests – considering it
Part 2: Database Integration Tests – understanding it
Part 3: Database Integration Tests – implementing it
In this third and last part of the series, I’m going to demonstrate the implementation of Database Integration Tests.
Below is the representation of the table wich will embrace our testing scenario:
Then you have the source code of a simple java implementation upon the usage of junit and dbunit frameworks.
The relevant piece of code is inside the class CustomerIntegrationTest.
At the method setup(), we ask dbunit to clean the customers table and then insert some new customers as input data for the first test.
At the second test, we ask dbunit to look for the created customer in the database and compare it with the existing on in the xml file.
I’ll leave preferedCustomers.xml and newCustomer.xml as a homework for you, if you intend to hack with this implementation.
By the way, this is the end of the series.
Hope you enjoyed!
Related posts:







