0
我正在为我的项目创建junit测试用例。我有下面的代码,在那里我想创建一个模拟,我正在使用junit和mockito核心jar。我试着用下面的代码,Junit测试用例与Mockito
System.setProperty("path.to.properties", "dummyPathToProperties"); //invalid Path
Properties properties = mock(Properties.class);
Resource propertyFile = new FileSystemResourceLoader().getResource("dummyPathToProperties");
when(PropertiesLoaderUtils.loadProperties(propertyFile)).thenReturn(properties);
有了上面的代码,它会引发错误,当模拟loadProperties方法。我怎样才能模拟一个弹簧静态类并返回我的模拟属性对象?
任何帮助将非常感激。