I have written the junit test case of a API helper class but when I am checking the code coverage, the helper class is showing as 0 percent. I am not sure what is the issue.
Here is the sample code:
public Class ClassHelper{
public Response invoke() {
ClassVO classVO = new ClassVO(pString);
ClassOutputVO outputVO = getSoapServiceBridgeProvider().getSoapServiceBridge(classVO).invokeProces()
...
return response
}
}
the testclass is given below:
@Test
public void testInvoke() throws Exception{
PowerMockito.whenNew(ClassVO.class).withArguments(Mockito.anyString()).thenReturn(mockVO);
Response actualResponse = (Response) classHelper.invoke();
can someone please help me with the issue? Its working with other helper classes but only happening with api helpers.
the working example has below:
@Component
public class TestHelper {
public Reponse updateRole(Request request) throws Exception {
ClassVO vo = new ClassVO();
vo.setRoleId(request.getRoleId());
vo.setRoleName(request.getRoleName());
Response response = new Response;
response.setRoleId(vo.getRoleId());
response.setRoleName(vo.getRoleName));
}
}
Test class:
@ContextConfiguration
@RunWith(PowerMockRunner.class)
@PowerMockIgnore("javax.management.*")
@PrepareForTest({ DriverManager.class })
public class TestHelperTest {
@InjectMocks
private TestHelper testHelper;
@Test
public void testUpdateRole() throws ADTMBaseException{
Request request = new Request();
request.setRoleId(8);
request.setRoleName(JUnitTestConstants.ROLE_NAME);
Reponse actualResult = testHelper.updateRole(request);
}