title: How to test method with scanner inside via jUnit?
body: <p>Here my test method : </p>
  
  <pre><code> @Test
  public void Should_Print_All_Groups_With_Less_Or_Equals_Student_Count() throws ClassNotFoundException, IOException, SQLException {
  
      SchoolDao schoolDao = new SchoolDaoImplementation();
      Class.forName("org.postgresql.Driver");
  
      assertEquals(schoolDao.findAllGroupsWithLessOrEqualsStudentCount("testDb.properties"), "check");
  
  }
  }
  </code></pre>
  
  <p>Here method which I want to test :</p>
  
  <pre><code> @Override
  public HashMap&lt;String, Integer&gt; findAllGroupsWithLessOrEqualsStudentCount(String pathToDatabaseProperties) {
  
      ConnectionFactory connectionFactory = new ConnectionFactory();
  
      Scanner scanner = new Scanner(System.in);
      System.out.println("Please, enter minimum number of students in groups : ");
      int numberOfStudents = scanner.nextInt();
      System.out.println(main.drawGroupNamesAndNumberOfStudents(main.replaceGroupNumberToGroupName(main.countNumberOfStudentsInGroups(numberOfStudents, pathToDatabaseProperties), connectionFactory.connectToDatabase(pathToDatabaseProperties))));
      return main.replaceGroupNumberToGroupName(main.countNumberOfStudentsInGroups(numberOfStudents, pathToDatabaseProperties), connectionFactory.connectToDatabase(pathToDatabaseProperties));
  }
  </code></pre>
  
  <p>But I don't know how can I test method with scanner inside ? </p>
  
  <p>Because now I run the test and program is loading and do nothing.</p>
  
  <p>So maybe smb can help and write properly test. Thanks in advance!</p>