I am writing a Junit test case using Mockito & PowerMockito in Java. Below are the code snippet:
ApplicationCovrgeCommonRules class has method checkForValidFormIdForCoverageTest() which needs to be tested. This method is calling another method (of same class) getCarirSysID() having return type String.
@Test
public void checkForValidFormIdForCoverageTest() throws Exception{
String caseId="caseId";
StateVO stateVO = new StateVO(); stateVO.setDeliveryState("AK");
Mockito.when(dsBean.getStateInfo(any())).thenReturn(stateVO);
String carirSysID="CarirSysID";
ApplicationCovrgeCommonRules applicationCovrgeCommonRulesMock=
Mockito.spy(applicationCovrgeCommonRules);
Mockito.doReturn(carirSysID).when(applicationCovrgeCommonRulesMock).getCarirSysID(caseId);
applicationCovrgeCommonRules is defined as:
@InjectMocks
ApplicationCovrgeCommonRules applicationCovrgeCommonRules;
While running this code, I am getting error as
> unnecessary Mockito stubbings FAILED
org.mockito.exceptions.misusing.UnnecessaryStubbingException