Skip to main content
Stack Overflow
  1. About
  2. For Teams

Timeline for Testing DAO Methods in Java: Fake Implementations vs. In-Memory Databases

Current License: CC BY-SA 4.0

11 events
when toggle format what by license comment
Jun 25, 2024 at 10:31 comment added Roman-Stop RU aggression in UA I would suggest to check this somewhat related question stackoverflow.com/q/145131/2231972
Mar 29, 2024 at 20:08 vote accept Kamil Gajdzinski
Mar 26, 2024 at 23:01 comment added M.P. Korstanje And you should probably take the test container tutorial as generic framework agnostic explanation of the principles involved. You will have to translate those principles back to Dropwizard. Or find someone who already did that.
Mar 26, 2024 at 23:00 comment added M.P. Korstanje I'm not familiar with Dropwizard but it looks like a reasonably flexibele framework and it supports DI. So you can probably find a place replace your DB connection with one provided by a test container. To insert tables a tool like Flyway or Liquibase might work. Then insert the remaining test data as part of the test. If that doesn't work, you may have to refactor your application to make it testable.
Mar 26, 2024 at 22:23 comment added Kamil Gajdzinski @M.P.Korstanje also in their example they send DbConnectionProvider in constructor. I use dropwizard and here common thing is passing DAO to constructor so it would be harder to adapt for using testcontainers
Mar 26, 2024 at 22:01 comment added Kamil Gajdzinski @M.P.Korstanje as I understand, I have to provide create table query for each table I want to use with testcontainers? Right now I don't have them in my code and I'm not ensuring that those tables exists so adding it would be time consuming. How do u handle this problem?
Mar 24, 2024 at 22:25 comment added M.P. Korstanje Test against your actual database software with a test container and spin up a companion service as part of your CI (or also use the test container, security policies allowing). testcontainers.com
Mar 24, 2024 at 18:27 answer added ndc85430 timeline score: 2
Mar 24, 2024 at 17:38 comment added Basil Bourque Using an H2 in-memory database makes a "more realistic test environment" only if you will be deploying an H2 in-memory database.
Mar 24, 2024 at 14:06 answer added Mark Seemann timeline score: 1
Mar 24, 2024 at 13:19 history asked Kamil Gajdzinski CC BY-SA 4.0 created from wizard

AltStyle によって変換されたページ (->オリジナル) /