For this class –
public enum Component { REDIS("Redis"); ........}
I was using below code in my test class which used powermock –
Component redis = Mockito.mock(Component.class); Whitebox.setInternalState(Component.class, "REDIS", redis);
But now I am migrating all powermock files to Mockito, how can I do the same thing with Mockito.
version I m using is 4.9.0
I tried using ReflectionTestUtils.setField(Component.class, "REDIS", redis);
but got error –
java.lang.IllegalStateException: Could not access method or field: Can not set static final
Arjun is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.