beryx / text-io

A library for creating interactive console applications in Java
http://text-io.beryx.org/
Apache License 2.0
342 stars 45 forks source link

Enhancement request: NullTerminal #9

Closed tonypiazza closed 6 years ago

tonypiazza commented 6 years ago

It would be useful for testing purposes to have a terminal type that just throws away all output. Similar to /dev/null in Unix/Linux world.

Thanks,

-Tony

siordache commented 6 years ago

I think the MockTextTerminal is what you need. It just stores the output in a string buffer, without actually printing anything. It also lets you provide preconfigured values for the input in order to test read operations. I use the MockTextTerminal to write Spock tests for text-io (see, for example, TextIoSpec.groovy and TextIoReadSpec.groovy).