I have a SpringBoot application and I am a configuration package with
@Configuration @EnableJpaAuditing public class PersistenceConfig { }
But PersistenceConfig does not fall into PersonRepositoryTest
@RunWith( SpringRunner.class ) @DataJpaTest public class PersonRepositoryTest {
However, if I change from @DataJpaTest to @SpringBootTest , PersonRepositoryTest will pick the configuration.
My structure
- main - java - config PersistenceConfig.java - domain Person.java - persistence PersonRepository.java Application.java // @SpringBootApplication - test - java - persistence PersonRepositoryTest.java
Testing for Improvements in Spring Boot 1.4 Testing the Persistence Layer with @DataJpaTest
Note: Running both annotations in the Test class still does not import the @SpringBootTest @DataJpaTest configuration
Question 1: When testing the save level using @DataJpaTest as correct (the best way in Spring Boot) to import the configuration package into my tests?
Question 2: Could work using @SpringBootTest be acceptable? I know that @DataJpaTest is also a meta annotation with reasonable auto-tuning for my database, including transaction management. But what if I don't need it?
spring spring-boot spring-data-jpa unit-testing configuration
Dachstein
source share