Tag: functional testing

使用Mockito模拟方法的局部变量

我有一个需要经过测试的A级课程。 以下是A的定义: public class A { public void methodOne(int argument) { //some operations methodTwo(int argument); //some operations } private void methodTwo(int argument) { DateTime dateTime = new DateTime(); //use dateTime to perform some operations } } 并且基于dateTime值,一些数据将被操纵,从数据库中检索。 对于此数据库,值通过JSON文件保留。 这使事情变得复杂。 我需要的是在测试时将dateTime设置为某个特定日期。 有没有办法可以使用mockito模拟局部变量的值?