-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Consider removing in-memory database configuration from slice tests #42360
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
I don't think so, at least |
Thanks for the suggestion but I don't think we can do this. In addition to @quaff's points above, we also know from experience that a significant portion of Spring Boot's user base cannot or does not use Docker for various reasons.
Thanks for spotting this. It's not moving things in the direction that you'd like, but I think we should correct this by adding |
In practice, I don't remember seeing a real world project that didn't use at least some custom SQL (or JPQL) statements. Using JPA/Hibernate also doesn't mean developers shouldn't leverage native (often vendor specific) capabilities of their RDMBS - quite a few Hibernate experts are actually trying to raise awareness of that. Finally, testing against an in-memory database makes it easier to hide issues caused by change of behavior when upgrading to a new Hibernate release.
That's fine, but shouldn't be a reason for Spring Boot to have something that's clearly not a best practice as a default. Also with the change they'd still be just an annotation away from opting in to auto-configured in-memory database. That's also more explicit and less magic, which is good thing from my point of view. Like I said, I've seen really a lot of I must say, when it comes to data access support, Spring Boot has some quite frustrating defaults (see OSIV/OEMIV). |
I'm not sure we have sufficient evidence to state, categorically as you have done above, that what Boot is doing here is "clearly not a best practice as a default". Reducing things to being a best practice or not being a best practice often strips away a lot of context from different people's situations and the different variables that have to be weighed up. If you're in a position to use Docker (and with some of their recent changes that probably means being in a position to pay for it), using a containerized database for integration tests could be the best choice given the situation. If you're not in a position to use Docker, then obviously you can't do that. Given a choice between using an in-memory database pretending to be your actual database and requiring everyone on a team and CI workers to have the actual database set up and running, using an in-memory database could be the best choice given the situation. With the changes in Boot 3.4, I think we're doing a pretty good job of catering for both of the situations described above. If you write an integration test using
Boot doesn't add an in-memory database to the classpath by default. The user has to opt in to using an in-memory database for testing by adding one to the classpath.
Haven't we addressed this in Boot 3.4? If there are still cases where |
To begin with, I'm aware of recent improvements made by #35253.
However, I'd still ask to consider removing in-memory database configuration from slice tests where it's used (
@JdbcTest
,@DataJpaTest
,@DataJdbcTest
) for the following reasons:@JooqTest
doesn't configure an in-memory database)In practice, I haven't worked on a project where data access layer was primarily tested using an in-memory database probably since ~2016 so that's a lot of occurrences of
@AutoConfigureTestDatabase(replace=NONE)
.The text was updated successfully, but these errors were encountered: