Last active
November 24, 2017 10:15
-
-
Save invkrh/93c455a4f751d755a1a5 to your computer and use it in GitHub Desktop.
input mocking for test need
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object test extends App { | |
import scala.collection.JavaConversions.asJavaEnumeration | |
import java.io.{ByteArrayInputStream, SequenceInputStream} | |
val inputs = Iterator("asdf", "qewr", "wert") | |
.map(x => new ByteArrayInputStream((x + "\n").getBytes)) | |
val in = new SequenceInputStream(asJavaEnumeration(inputs)) | |
Console.setIn(in) | |
val a = readLine() | |
val b = readLine() | |
val c = readLine() | |
println(List(a, b, c)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
and this was also helpful https://stackoverflow.com/questions/33569920/how-to-test-system-out-println-by-mocking