I have a set up like:
Bean class:
private final Map configCache = new HashMap<>();
@PostConstruct
private v
Mockito isn't calling @PostConstruct
-- Spring is. You say that in your test you use @Autowired
, which is not a Mockito annotation.
If you meant to use @Mock
, you'll find that Mockito won't call your @PostConstruct
method.
In other words, write your test class like this:
@Mock Bean myBean;
@Before
public void before() {
MockitoAnnotations.initMocks();
}