Skip to content

Instantly share code, notes, and snippets.

@Hromenique
Created November 27, 2017 13:18
Show Gist options
  • Save Hromenique/3317116e87a529a523545d21c0cd5805 to your computer and use it in GitHub Desktop.
Save Hromenique/3317116e87a529a523545d21c0cd5805 to your computer and use it in GitHub Desktop.
Configuração para executar testes com Spring excluíndo classes dos contexto de injeção
@Configuration
@ComponentScan(basePackages = "br.com.hrom",
excludeFilters = {
@Filter(type = FilterType.REGEX, pattern = "br.com.hrom.queue.*")
})
//@EnableAutoConfiguration and @Enable???Repositories in case of one or more depedencies need database repositories.
//Otherwise errors will occurrs when start the container
@EnableAutoConfiguration
@EnableMongoRepositories(basePackages = "br.com.hrom")
public class MyTestConfig {
}
@RunWith(SpringRunner.class)
@SpringBootTest(classes = MyTestConfig.class)
@TestPropertySource("classpath:application-tests.properties")
public class MyTest {
//My tests
@Test
public void test1(){
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment