public class FileUtil {
public void methodOne(Bean bean) {
StringBuffer profileControlValue = new StringBuffer();
profileControlValue.append(bean.getName()).append(bean.getDesc());
String sourcePath = "path to save";
try (Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(sourcePath.toString())))) {
writer.write(profileControlValue.toString());
} catch (IOException e) {
e.printStackTrace();
}
}
}
我想使用Mockito / PowerMockito编写上述方法的Junit测试用例。 基本上,我有一个接受Bean并处理值并将其写入文件的方法。