0

Please help me how can I write test case for private void method which takes pojo class as an argument and set some class methods in side. I mean inside that method some setmethods are calling. This private method is called in constructor but i want to test or write test case for that private method.

Ex:

private void M1(Dto obj1) {
   anotherclass.setSometMethod(someClass.getId());
}

Please let me know how we can do it using PowerMockito. I don't want to use Reflection.

Thanks in advance

  • 2
    Does this answer your question? [Testing Private method using mockito](https://stackoverflow.com/questions/8799439/testing-private-method-using-mockito) – JonK Feb 11 '20 at 10:25
  • Hi Jonk, could you give an example, I tried that example which you have mentioned link but not working below is example which i need to test. private void initializeFields(final DeviceGroupDTO deviceGroupDTO) { if (deviceGroupDTO != null) { this.deviceGroupName.setValue(deviceGroupDTO.getName()); if (deviceGroupDTO.getCustomer() != null) { this.customerSelector.setSelected(deviceGroupDTO.getCustomer().getId()); } } – Yeruva Nag Feb 11 '20 at 11:37
  • 1
    Please add code by editing your question instead. You should also add the testcase you have tried to write and any exception/error you now have. – second Feb 11 '20 at 12:06

0 Answers0