I have the following setup :
Class to test : SeriesOffset
which extends BaseDisplayOption
Test Class : SeriesOffsetTest
When creating an object of the SeriesOffset
class to test it, the constructor of the same makes a super call which then makes the following method call :
logger = LoggingService.getLog(this.getClass());
where LoggingService
is an abstract class and getLog(Class<?> clazz)
is a static method with a generic class parameter. This very method call needs to be mocked. I created a mock implementation for the same with a class called ILogImpl
and this is how I am trying to test it:
ILogImpl a = new ILogImpl();
PowerMockito.mockStatic(LoggingService.class);
PowerMockito.when(LoggingService.getLog( SeriesOffset.class)).thenReturn(a);
But this method doesnt seem to work and it calls the real implementation instead of the mock one that I need it to call. The error trace is the following : error trace