2
votes

I need to use Mockito/Power Mockito to mock a private method. I am using testng, and most of the examples I see online are for mocking private method using PowerMock+Junit - Mocked private method with PowerMock, but underlying method still gets called

Can anyone please point me to examples where I can use Power Mockito+testng. I have been looking for a while, but no luck so far.

3

3 Answers

0
votes
0
votes

i found the way . please try this

 @Test
        public  void  commandEndHandlerTest() throws  Exception
        {
            Method retryClientDetail_privateMethod =yourclass.class.getDeclaredMethod("Your_function_name",null);
            retryClientDetail_privateMethod.setAccessible(true);
            retryClientDetail_privateMethod.invoke(yourclass.class, null);
        }