There is class A, in which the @ PostConstruct annotation stands above one of the methods, it is injected into another class B, how to make class A correctly, so that the code of the method with @PostConstruct would not be executed in tests? class B too mok
1 answer
Here is an example that works for the latest Spring Boot + spring-testing + JUnit
@SpringBootTest(classes = FileAgentApplication.class) @RunWith(SpringJUnit4ClassRunner.class) public class BTest { @MockBean private A a; @Autowired B b; @Test public void test1(){ Assert.assertNotNull(a); Assert.assertNotNull(b); } } |