Write cross-platform unit tests that handle assertions on line endings
I'm using JUnit to test the printed output of a program. I'm doing this by setting System.out to my own PrintStream which prints to a ByteArrayOutputStream. My tests usually look like this: assertEquals("Some line of text\r\n", output); I'm interested in how I might make this code work across platforms. If I run these tests on linux, all these tests will fail. I could write more complicated tests, which accept either \r\n or \n in the output, but I'd like to keep the tests simple if possible. Is there a way to set the type of newline printed by println()?
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.