How to fill database in tests for Spring projects if smth different from CrudRepository is used? #2347
Unanswered
EgorkaKulikov
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Consider generating integration tests for the method in Spring project that interacts with the database. In such case we should save some data in the database and verify that it is processed correctly.
For example, if we test a method
The following code is generated as a part of test method
This code is generated under the assumption that repositories in user project implement
CrudRepository
that hassave
method. This assumption is highly likely correct.However, there is a marker interface
Repository
in Spring that does not have any specified method to save. What should we do?Also, user may have some non-Spring libraries for database processing, like
mybatis
and it seems to be very difficult to deal with. Just one of the reasons is that some not compatible withH2
(used in concrete execution) dialect of SQL may be used.Beta Was this translation helpful? Give feedback.
All reactions