I have a SpringBoot Application and I a config package with
@Configuration
@EnableJpaAuditing
public class PersistenceConfig {
}
After @georges van post I have found out that ALL configuration classes get also picked up by just adding one line in the test:
@RunWith( SpringRunner.class )
@DataJpaTest
@ComponentScan(basePackages = "com.basepackage.config")
public class PersonRepositoryTest {
// Tests ...
}
If someone only wants ONE specific configuration class you can do:
@RunWith( SpringRunner.class )
@DataJpaTest
@ContextConfiguration(classes=MyConfig.class)
public class PersonRepositoryTest {
// Tests ...
}
Or multiple classes with:
@ContextConfiguration(classes={MyConfig1.class, MyConfig2.class})