参考:https://blog.csdn.net/qq_39967911/article/details/103237291

下面是例子,单元测试要从控制台接收参数

@Test
public void test() {
    Scanner scanner = new Scanner(System.in);
    int i = scanner.nextInt();
    System.out.println(i);
}

但是运行之后,会发现控制台是无法输入任何字符的,哪怕是复制粘贴进去。

IDEA 单元测试System.in 没办法输入

解决方法

help ->Edit Custom VM Options... -> 加上

-Deditable.java.test.console=true

这句话重启IDEA 就好使了

IDEA 单元测试System.in 没办法输入

IDEA 单元测试System.in 没办法输入

相关文章:

  • 2020-02-29
  • 2021-04-30
  • 2021-05-13
  • 2021-06-17
  • 2021-06-04
  • 2021-09-17
  • 2021-11-26
猜你喜欢
  • 2021-09-16
  • 2021-05-05
  • 2021-11-28
  • 2021-08-14
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案