When testing a DAO i follow these rules:
- Use an in-memory database
- Reset database data for every test
This works well for selecting from the database. I setup the database with the data needed for the select, call my DAO and verify, that the returned object has the right values.
But when testing insert, update and delete it gets ugly. I have to write a custom select statement to verify, that the correct data was inserted/updated/deleted in my database. So when im finished writing the tests i could just aswell test my tests again.
Some people on the web suggest mocking literally everything, but that doesn't really test anything imo.
So, how does one test a DAO?