1

I have an object with a message that gets a stream and print into it.
My problem is testing that I am printing the right string.
I could do it with output redirection and a testing script, but I would rather do it using the assert of the TestCase class, if that is possible.
Thanks for any help :)

Sam DeHaan
  • 10,246
  • 2
  • 40
  • 48
Mugen
  • 8,301
  • 10
  • 62
  • 140

1 Answers1

2

You can create a stream that writes to an in-memory string with WriteStream on: String new.

Send contents to that stream for retrieving the string contents.

That should help you test your code.

Alex Jasmin
  • 39,094
  • 7
  • 77
  • 67