【PowerMockito:编写单元测试过程中原方法使用@Value注解注入的属性出现空指针】
错误场景
���行到@Value的属性时会出现空指针,因为@Value的属性为null
解决方法
在测试类调用被测试方法前,提前设置属性值,属性可以先自己定义好
ReflectionTestUtils.setField(endpointConnectionService, "exportUdpList", list);
The End
���行到@Value的属性时会出现空指针,因为@Value的属性为null
在测试类调用被测试方法前,提前设置属性值,属性可以先自己定义好
ReflectionTestUtils.setField(endpointConnectionService, "exportUdpList", list);