mag*_*ter 1 java testing junit filenotfoundexception ioexception
我正在为一段代码编写测试,其中包含一个IOException catch,我试图覆盖它.try/catch看起来像这样:
try {
oos = new ObjectOutputStream(new FileOutputStream(cacheFileName));
} catch (IOException e) {
LOGGER.error("Bad news!", e);
} finally {
Run Code Online (Sandbox Code Playgroud)
最简单的方法似乎是让FileOutputStream抛出一个FileNotFoundException,但也许我会以错误的方式解决这个问题.
有人在那里有任何提示吗?
| 归档时间: |
|
| 查看次数: |
2028 次 |
| 最近记录: |