I have MyTestClass1:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
@DirtiesContext
public class MyTestClass1 {
@Configuration
static class Config {
@Bean
public FileSerivce fileService() {
return Mockito.mock(FileSerivce.class);
}
}
}
and the other test class MyTestClass2:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
public class MyTestClass2 {
@Autowired
FileSerivce fileService;
}
Problem is, that in class MyTestClass2 fileService is mock autowired from MyTestClass1 instead of real fileService. When I remove mock definition from MyTestClass1, MyTestClass2 uses real fileService as i need.
How can i remove MyTestClass1 side effect on MyTestClass2 ?