stefanbirkner / system-rules

A collection of JUnit rules for testing code which uses java.lang.System.
http://stefanbirkner.github.io/system-rules
Other
546 stars 71 forks source link

Add methods to access raw stdout/stderr logs #66

Closed marcvinyals closed 5 years ago

marcvinyals commented 6 years ago

I would like to test some code that writes raw binary data to stdout. To do so I believe I need access to the underlying byte array, since a sequence of bytes may not be a valid string. Therefore I suggest to add a method getLogBytes to SystemOutRule and SystemErrRule. Let me know if you think this makes sense and if so I will add documentation and tests to this PR.

stefanbirkner commented 6 years ago

Thanks for your contribution. I would like to add it to System Rules. Do you have time to write the tests for the new feature?

marcvinyals commented 6 years ago

I should be able to write some tests later this week.

marcvinyals commented 6 years ago

I added a basic test that verifies properly handing non-utf-8 data. I would say that proper behaviour with respect to muting, etc. is well covered by the existing tests, do you think something more is needed?

stefanbirkner commented 6 years ago

Thanks for adding the test. I do my best to get a release out during next week.

stefanbirkner commented 5 years ago

System Rules 1.19.0 adds a new method getLogAsBytes(): f4782ebfd72c08bd3f00aa04ad20fe499c5463b4