title: How to mock scala readLine
body: <p>I want to write a unit test for my main function where there is a  <code>readLine()</code> loop.</p>
  
  <p>I have tried the following which is java based. I think <code>readLine()</code> might need <code>System.in</code> as <code>inputStream</code>. But it doesn't work. ScalaTest is blocked on the <code>readLine()</code> waiting for inputs.</p>
  
  <pre><code>"readLine" should "work" in {
    val in = new ByteArrayInputStream("abc".getBytes)
    System.setIn(in)
    readLine() === "tester"
  }
  </code></pre>
  
  <p>Any ideas? Thank you.</p>