使用Intellij和JUnit从控制台读取System.in [英] Reading System.in from the Console using Intellij and JUnit
本文介绍了使用Intellij和JUnit从控制台读取System.in的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
通过Idea中的主程序运行代码时,以下代码可以很好地工作
The following code works nicely when running the code through a main in Idea
System.in.read()
但是junit方法中的相同代码不起作用
However the same code inside a junit method is not working
public void testConsoleRead()
{
System.in.read();
}
任何想法如何使这项工作有效,或类似的方法?
Any idea how to make this work, or something similar ?
推荐答案
您需要使用-Deditable.java.test.console=true
启动IDE(例如,通过帮助">编辑自定义VM选项..."),请参见此评论.
You need to start the IDE with -Deditable.java.test.console=true
(e.g. via "Help" > "Edit Custom VM Options..."), see this comment.
这篇关于使用Intellij和JUnit从控制台读取System.in的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文