JUnit4 + Java
@RunWith(SpringRunner.class)
@ImportAutoConfiguration(JacksonAutoConfiguration.class)
@Import(MyService.class)
@ContextConfiguration
public class MyServiceTest {
}
The main point here is not to put @SpringTest annotation on MyServiceTest
---
JUnit5 + Kotlin
@Configuration
@ComponentScan
class AutotestApplication
@ExtendWith(SpringExtension::class)
@SpringBootTest(
classes = [AutotestApplication::class],
webEnvironment = WebEnvironment.NONE
)
@ImportAutoConfiguration(value=[RabbitAutoConfiguration::class])
abstract class AbstractTest {
}
The main point here is not to put @SpringBootApplication on AutotestApplication