I want to unit test an API that parses a file for specific patterns.
The fragments of text returned, may be multiline and contain tabs etc. I.e. the text in the file is formatted with new lines and tabs to be readable by a user (same as we nicely indent an xml file).
Problem: Since Java
does not offer the option to define such strings (which will be the expected outcome in an Assert
check of the API output) how are such problems handled?
I thought e.g. to save all the expected output in a file with some kind of special character to mark beginning and end of each expected fragment but I thought that perhaps there is a standard approach to such a problem.
Is there a better option?
Update: Example:
This is an example String.
This is an inner part of the string. Another part. Another also.
This is also an inner part.
Now an outer. This is the outer example string.