如何测试私有方法

使用 spring 的 ReflectionTestUtils

ReflectionTestUtils.invokeMethod(object, method , args);

导入依赖:

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-test</artifactId>
    <version>4.1.6.RELEASE</version>
    <scope>test</scope>
</dependency>  

猜你喜欢

转载自www.cnblogs.com/xmsx/p/11610812.html