Wednesday 23 January 2019

Junit-Mockito: Mock private field initialization

https://stackoverflow.com/questions/36173947/mockito-mock-private-field-initialization

In case you use Spring Test try org.springframework.test.util.ReflectionTestUtils
 ReflectionTestUtils.setField(testObject, "person", mockedPerson);


No comments:

Post a Comment

40 Latest Interview Questions and Answers on Spring, Spring MVC, and Spring Boot

  40 Latest Interview Questions and Answers on Spring, Spring MVC, and Spring Boot 1. What is Tight Coupling? When a class (ClassA) is depen...