Issue
How to mock the EntityManger in springboot mockito integration test
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
classes = [EntityManager::class],
properties = [
"spring.datasource.url=jdbc:mysql://localhost:3306/db"
]
Should i put EntityManager in the classes or i should to mock it differently
Solution
I delete the EntityManager from the classes and i forget it from my mocke's class beacause i use JdbcAggregateOperations in the JPA layer.
My new configuration for the integration test is simply like this
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
classes = [],
properties = "spring.datasource.url=jdbc:mysql://localhost:3306/db"])
class DemoApplicationTests(@Autowired val restTemplate: TestRestTemplate,
@Autowired private val repository: UserRepository) {`
thank you
Answered By - mjedli
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.