title: junit5 test scanner on system.in
body: <p>How to create a test method using junit5 for the following method?</p>
  
  <pre><code>public static String readFromDBOrFile() {
    String fileOrDB;
    do {
      Scanner scanner = new Scanner(System.in);
      System.out.print("Select between reading from 'file' or 'DB': ");
      String line = scanner.nextLine().toUpperCase().trim();
      fileOrDB = !line.equals("FILE") &amp;&amp; !line.equals("DB") ? null : line;
      if(fileOrDB == null) 
        System.out.println("Not a valid choice. Try again");
    } while(fileOrDB == null);
    System.out.println("Reading from : '" + fileOrDB + "'");
    return fileOrDB;
  }
  </code></pre>