How should I unit test methods which their intent is querying the database and return some data? For other situations I can just mock the objects but in this case which I want to test whether they return the correct data, how should I check it isolated from db? Should I use some kind of special db? But then how should I configure that new db to work like the other one with all those columns, etc?
Thanks.
Update: Thanks to everyone, their responses leaded me to the correct path. I finally used debry. I just added a new persistence.xml for that. No other significant changes and it seems to be working now.
The question is what behavior do you need to unit test? If you mocked out the database then you’ve tested all the important logic. Your database adapter will either work or not work, which you can verify in integration/acceptance tests against a real database.