Today we upgraded to the newest version of FitNesse (20090214) and suddenly all tests trying to match multiline Strings weren’t working anymore. We used the approach given here and defined variables that had line breaks in their value:
!define expected_result {some
multiline
text}
These variables could then be simply used in the test tables:
|${expected_result}|
But with the new version, line breaks in variable definitions are treated like spaces and the expected result becomes “some multiline text” without the newlines.
A different solution to get preformatted text, to use {{{ … }}}, isn’t working in test tables and therefore is of no use in our case.
So we decided to encode all occurences of \n by some simple comparable string (which isn’t used elsewhere most likely) in the fitnesse-tests and on the comparator side. If you have a better solution for this problem – please let us know!




Are You a real developer?
*** old/src/fit/Parse.java Sat Mar 21 08:08:50 2009
— new/src/fit/Parse.java Sat May 09 20:46:01 2009
***************
*** 133,138 ****
— 133,139 —-
}
public static String unformat(String s) {
+ s = s.replaceAll(“”, System.getProperty(“line.separator”));
int i = 0, j;
while ((i = s.indexOf(‘= 0) {
if ((j = s.indexOf(‘>’, i + 1)) > 0) {
Changes to the Slim test system left as an exercise for the reader :->
And your blog system needs an update too…
That is “<br */?>” in the replaceAll.
Sorry, can’t follow your code. Seems like there are a lot more characters missing, not only the br in the replaceAll… and we’ll check the commenting bug, thanks for the hint!
Two more chars are missing, but that’s not important. Probably I should be a bit more verbose:
- This is an output from a diff programm. So it’s not possible to understand the code without knowing the context. You can see that I have added a line replaceAll to a method called unformat.
- My suggestion is to remedy the issue instead of using a workaround.
- This is a patch for the fit part of fitnesse. Source: http://github.com/unclebob/fitnesse/downloads
HTH