Timeline for What are some best practices for populating and using a test database?
Current License: CC BY-SA 3.0
5 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jul 22, 2011 at 11:03 | comment | added | maple_shaft♦ | @sangfroid, This is a good point and something I can benefit from too. Hibernate logic and HQL queries specifically don't unit test well in the traditional sense. In the past I depended on integration unit tests to verify the functionality but these were nearly always environment specific and brittle. DBUnit was mentioned in a previous answer and looks like it deserves a second look. | |
| Jul 21, 2011 at 23:47 | comment | added | sangfroid | Well, I should mention that I'm new to Hibernate. So it actually is important for me to test that I've done all my hibernate stuff correctly. Also, it seems like a lot of operations couldn't be tested with a mocking framework. For example, you have a method that returns a bunch of records. How can you test that method actually returns a bunch of records if you don't have a database for it to run against? | |
| Jul 21, 2011 at 20:19 | comment | added | Gary | +1 for suggesting mocking frameworks over database solutions. The database approach introduces frequently unnecessary complexity which mostly ends up testing Hibernate rather than your DAOs. Also, I'd add JMockit in that list - it does everything. Immutable String? I don't think so. | |
| Jul 21, 2011 at 19:13 | comment | added | sangfroid | Yes, I already use Mockito for unit tests. But I also want to do (integration?) tests that reach out to the DB. | |
| Jul 21, 2011 at 19:10 | history | answered | maple_shaft♦ | CC BY-SA 3.0 |