Avoid platform-dependent line separator in part 06 assertions
Closed this issue · 1 comments
simonbasle commented
In Part06Request
there are two tests that assert multiple lines of logs as a single String
.
The expected String
in these assertions thus includes line separators, which happen to be platform dependent (explicit "\n"
included).
The tests should be rewritten to avoid that, and the best way of doing so is to assert the logs as a List<String>
(one per line) instead of a multi-line single String
.
In the case of experimentWithLog()
:
- split the stream's input on
System.lineSeparator()
rather than\n
- don't join the filtered stream but collect to
Collectors.toList()
, thus turning thelog
variable into aList<String>
- assert the list
containsExactly
each line of log (multiple strings without a\n
)
In the case of experimentWithDoOn()
:
- assert a splitted
logConsole.toString()
, onSystem.lineSeparator()
, rather than a single unsplitted String` - assert it
containsExactly
6 strings (one per line, without referring to the\n
)
This change can be made on master
and will be easily forward-merged to solution
and techio_course
, although it should be tested on solution
locally.
simonbasle commented