Skip to content

Add Tip that h2 needs to be in your class path for @DataJpaTest to work. #16714

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Conversation

Tetsuya3850
Copy link
Contributor

@Tetsuya3850 Tetsuya3850 commented May 3, 2019

Docs "46.3.12 Auto-configured Data JPA Tests" doesn't specify the necessity to configure an in-memory database. It reads as if everything "just" works.
https://docs.spring.io/spring-boot/docs/2.1.4.RELEASE/reference/htmlsingle/#boot-features-testing-spring-boot-applications-testing-autoconfigured-jpa-test

As consequence, I experienced the same issue as indicated in this stack overflow QA.
https://stackoverflow.com/questions/40659912/spring-boot-starter-test-cannot-run-database-integration-test

So, I suggest clarifying that you need to add an embedded in-memory database for setup.

"46.3.12 Auto-configured Data JPA Tests" read to me that it all works with zero config. However, I received the following error message in my try.

Failed to replace DataSource with an embedded database for tests. If you want an embedded database please put a supported one on the classpath or tune the replace attribute of @AutoConfigureTestDatabase.

I added h2 to my pom.xml and it worked.

The same issue was indicated in this stack overflow QA.
https://stackoverflow.com/questions/40659912/spring-boot-starter-test-cannot-run-database-integration-test

So, I suggest clarifying in the docs that you need to add an embedded in-memory database for this to work.
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 3, 2019
snicoll added a commit that referenced this pull request May 4, 2019
@snicoll
Copy link
Member

snicoll commented May 4, 2019

You've edited your first comment that quoted the error message we produce

Failed to replace DataSource with an embedded database for tests. If you want an embedded database please put a supported one on the classpath or tune the replace attribute of @AutoConfigureTestDatabase.

I think that error message is quite explicit on its own. I agree the doc could be a bit more explicit that it does so if it's on the classpath, this is not a requirement at all actually. I've rephrased that in 680ac85

Thanks for the PR, in any case!

@snicoll snicoll closed this May 4, 2019
@snicoll snicoll added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged labels May 4, 2019
@Tetsuya3850
Copy link
Contributor Author

I agree with your rephrase! Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: declined A suggestion or change that we don't feel we should currently apply
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants