Может кому-то понадобиться, видел в чате, что в юнитах такое не требуется, но мало ли
@org.junit.Test public void getNumber() { InputStream sysInBackup =
System.in; ByteArrayInputStream in = new ByteArrayInputStream("5".getBytes()); System.setIn(in); Scanner scanner = new Scanner(in); int userInput = scanner.nextInt(); assertEquals(5, userInput); System.setIn(
System.in); }