Question
The user wants to input something from the console when running a JUnit test in IntelliJ IDEA. But seems that IDEA doesn't support this feature.
@Test
public void testScanner() throws Exception{
Scanner scanner = new Scanner(System.in);
String line = scanner.nextLine();
System.out.println(line);
scanner.close();
}
Answer
By default, input in the JUnit test console is disabled in IDEA. Click Help | Find Action from the main menu, type Registry..., select it, and in the opened list, find and enable the editable.java.test.console options there, without a restart, the IDEA's console will accept keyboard input now.
Note: this feature isn't supported in other languages such as Kotlin.
Comments
0 comments
Please sign in to leave a comment.