I want to be able to put preformatted text (i.e. containing line breaks) into a single cell of a FitNesse fixture table. Is there a way to manipulate the FitNesse wiki markup to do this?
Asked
Active
Viewed 7,019 times
5 Answers
19
Use !- -! to get multiline table cells and {{{ }}} to get preformatted text. The {{{ has to be outside the !-
For example:
|sql|
|{{{!- SELECT *
FROM bar
WHERE gaz = 14
-!}}}|

Johannes Brodwall
- 7,673
- 5
- 34
- 28
-
1Thanks. Note that the `{{{ … }}}` inserts ` – `. This may not be what you want. I saw using setHeader / setHeaders in RestFixture. `!- … -!` was what was needed.ctrl-alt-delor Jan 17 '14 at 09:35
-
This doesn't seem to work with FitNesse release 20130530; the cell value isn't formatted and and the curly brackets appear in the rendered page. – Kenny Evitt Sep 04 '14 at 13:12
-
This doesn't work if you want variable substitution within the formatted text! – Markus L Jun 22 '16 at 11:06
2
One way to do this is to define a variable with the multi-line text and then refer to this from the table cell:
!define sql { SELECT *
FROM bar
WHERE gaz = 14
}
|sql|
|${sql}|

Matthew Murdoch
- 30,874
- 30
- 96
- 127
-
Hmmm... It seems to work. However I prefer your approach - I'll give it a try. Thanks. – Matthew Murdoch Feb 26 '09 at 12:15
1
richard's comment on Johannes Brodwall's answer worked for me, i.e. you don't need the "formatted 'as is'" line/block markup, just the "'as-is'/escaping" character formatting so the following is sufficient if you don't need or want the pre-formatted style too:
|sql|
|!-Some text
that spans
multiple lines.
-!|

Community
- 1
- 1

Kenny Evitt
- 9,291
- 5
- 65
- 93
1
This way allows you to keep a table row on the same line in your source code :
| col1 | col2 |
| !- col1 cell <br /> with line break -! | col2 cell without line break |

Michael Técourt
- 3,457
- 1
- 28
- 45
1
The way that ended up working best for me was using a couple of the solutions listed above together. Defining a variable and using the !- -!
define myVarWithLineBreaks {!-This is my
text with line
breaks-!}
|col |col2 |
|${myVarWithLineBreaks}|other value|

Jason Slobotski
- 1,386
- 14
- 18