What do I use instead of Whitebox in Mockito 2.2 to set fields?

后端 未结 5 1946
Happy的楠姐
Happy的楠姐 2020-12-16 10:22

When using Mockito 1.9.x I have been using Whiteboxto set values of fields to \"inject\" mocks. Se example below:

@Before
public void setUp() {
         


        
5条回答
  •  执念已碎
    2020-12-16 11:02

    If you are using Spring (the spring-test library specifically), you can simply use ReflectionTestUtils.setField instead of Whitebox.setInternalState

提交回复
热议问题