Configuring base package for component scan in Spring boot test

Good to add the test config above I have the following in test config and any test case. I am new to spring boot test but it work. Let me know, if I am wrong.

    @Configuration
    @ComponentScan("au.some.spring.package")
    public class TestConfig {
    }
    @RunWith(SpringRunner.class)
    @EnableAutoConfiguration
    @SpringBootTest(classes= TestConfig.class)
    @TestPropertySource({"classpath:application.yml", 
    "classpath:env-${testing.env}.properties"})
    public class DBDmoTest {

        @Autowired
        PartyRepository partyRepository;
        @Test
        public void test(){
            Assert.assertNull(partyRepository.findByEmailIgnoreCase("[email protected]"));
        }
    }

Leave a Comment

tech