views:

63

answers:

2

Is there any testing framework for Data access tier? I'm using mysql DB.

+1  A: 

If you are using ORM ( such as Hibernate), then the testing for DAL is easy. All you have to do, is to specify a test config involving in memory sqlite database and then executing all your DAL tests against the sqlite. Of course you need to do a proper data population, schema definition in the first place.

Dbunit will help you here.

Ngu Soon Hui
Thanks, I'm using TestNG to test business tier. Is this a good idea to use Dbunit for data access tier? Any suggestion?
Thomman
Yes, it is. It allows you to create data population faster than you can by hand
Ngu Soon Hui
A: 

Why do you need a database test tool?

Use your services (or DAOs) to populate the database. Otherwise you're going to duplicate your fixture state in your tests and your domain logic in your fixtures. This will result in worse maintainability (most notably readability).

If you get weary of inventing test data think about tools like Quickcheck (there are ports for all major languages).

Thomas Jung