idea使用junit测试无法在控制台输入问题


今天在学习的过程中发现,当使用junit进行测试的时候,测试方法中如果有scanner输入的情况是无法进行输入的。

解决方式:
1、进入help->Edit Custom VM Options

2、添加一行:
-Deditable.java.test.console=true

3、重启IDEA

重启步骤:

1)点击File–>Invalidate Caches进入重启窗口
2)选择重启方式,四个按钮,一共三种重启方式:
  ① Invalidate and Restart 清空缓存并重启。
  ② Invalidate 清除缓存,下次打开重启。
  ③ Cancel 取消。
  ④ Just Restart 重启。

解决方式转载于: