Data layer testing with @DataJpaTest

Hi!

When I want to test my data layer in a usual Spring Boot application, I use a @DataJpaTest annotation to instantiate my JPA repository tests. However, I didn’t manage to make it work in Jmix, I get a NoSuchBeanDefinitionException: EntityManagerFactory not present. So, there are the questions:

  1. In Spring Boot I use Hibernate, and there everything is configured automatically. Should I perhaps somehow manually instantiate EntityManagerFactory and TestEntityManager when working with EclipseLink an Jmix?
  2. Or is there any other conventional way to test the data layer in Jmix, without rising the whole context using a @SpringBootTest?

Are you using JmixDataRepository or JpaRepository for your data repositories?

I’m using JmixDataRepository

Then @DataJpaTest is certainly not enough anyway.
Your repositories actually invoke DataManager and a lot of other beans not related to JPA. You need the full context.

1 Like

Ah, I see, of course. Thank you.