Recently I started creating test reports in our company's Twiki, which is already used for project management
and knowledge base.
Below you find some formatting tricks that I use for consistent rendering and topic automation.
Tables
For compact presentation of test conditions I wanted a two column table, like in the image shown.
But alas, in the right column I need structured text which is not possible with Twiki's lightwight table implementation.
I considered some solution:
HTML hacks wich are seen all around the twiki.org website. This is hard to maintain and if more than one person is doing it a consistent style is not likely to be seen.
Installing the MediaWikiTablePlugin. The syntax is weired, although I didn't test it. More worse: My team (including me) is not familiar with the syntax.
I came up with some parameterized variables (macros) which hide the nasty HTML details. I was inspired to this solution after having seen some obscure wikimedia templates.
Table Macros
The macros are like this:
* Set DTABLE = <div style="%DTABLE_STYLE%"><table cellpadding="6" border="1" rules="all" class="twikiTable">
* Set DTABLEROW = <tr valign="top" ><td> %DEFAULT% </td><td>
* Set DTABLEEND = </td></tr></table><div>
Read the "D" as in data-table, or choose a better name for yourself.
The macros are stored in TWikiPreferences, so they can be used in any test report.
Consider this example:
%DTABLE%
%DTABLEROW{"*Standards*"}%
IEC 60068-2
%DTABLEROW{"*Parameters*"}%
* 70 °C
* 24 h
* 1 h temperature rise/fall
%DTABLEROW{"*Device* %BR% *under Test*"}%
Janz Tec emPC-A500
* SY-IPC-82000
* Freescale i.mx51 (600MHz)
* 256 MByte RAM
Software
* Linux 2.6.35
* Perl Testsuite running
* memory test
* netio (eth0, eth1)
* CAN selftest (testself2)
* serial port loopbacktest (sertest -c 3)
%DTABLEEND%
I think this is quite readable. It renders as:
Standards
IEC 60068-2
Parameters
70 °C
24 h
1 h temperature rise/fall
Device under Test
Janz Tec emPC-A500
SY-IPC-82000
Freescale i.mx51 (600MHz)
256 MByte RAM
Software
Linux 2.6.35
Perl Testsuite running
memory test
netio (eth0, eth1)
CAN selftest (testself2)
serial port loopbacktest (sertest -c 3)
Table Macro ExplanationDTABLE
This macro is used to spit out the start of the table. It has an optional parameter DTABLE_STYLE which can be used
to control the positioning of the table. You can use CSS style parameters here.
DTABLEROW
This macro starts a new (or the first) row. It takes the content for the first column as it's default parameter. Hence
it is referred as %DEFAULT% inside the macro. It is passed to the macro without a parameter
name (refer to the example above).
DTABLEEND
This macro ends the table by closing all open HTML tags.
More Table Ideas
The above macros utilize the twiki CSS table styles. You might not like them as
the grid is missing vertical lines (although some browsers show them)
the grid is very light, which makes the lines disappear on some TFT screens due to color inversion
You could add your own styles inside the twiki CSS files and refer to them. If you cannot change the CSS files, you can also hack
the styles into the macros as shown below (names changed so both versions can be tested in paralell). Note that
boarder-color is not inherited from <table> to <td>, so it must be specified for each cell.
Throughout my test report TWiki topic each performed test has its heading with a subsequent
subheading Test result. This is written as follows.
---++ High Temperature Operation Test
:
---++++!! Test result
| High temperature operation test (70 °C) | %ICON{"choice-yes"}% | _optional comment_ |
The table renders as.
High temperature operation test (70 °C)
optional comment
Well, it would be nice to have a summary of all the test results at the beginning of the report. However
this is more than a simple %TOC% can do.
How to do it?
I use one of my favorite plugins for this purpose: FilterPlugin. This plugin searches for
any text (a Twiki syntax tables in my case) and inserts them into the topic where you need it:
Filter Plugin Explanation
The plugin searches the raw topic text due to the setting expand="off". It searches
it's own topic due to topic="%TOPIC%".
pattern controls what is matched:
^---\+\+\+\+!* + - Matches for the heading syntax ---++++ at the start of a line (due to ^). This may optionally followed by ! if you prefer to hide this heading from the table of contents. Finally + (space followed by plus) allows one or more spaces.
Test result[\r\n]* - This part of the pattern matches for the heading text (exact match) followed by the line break. [\r\n]* allows any sequence of CR or NL characters, so we even handle one or more empty lines or CRNL sequences.
(\|.*?\|)$ - This finally matches the TWiki table, which is a line that starts and ends with |. Between those, it matches for any character but uses the special non-greedy *? quantifier to match only as little content as necessary. Using the greedy quantifier (*) here would match as much as possible. This could start one one line and match up to the end of a TWiki table many lines later. Anything between the brackets (the table line) is remembered for later use.
format is utilized to produce output each time the pattern matches. In this case it is easy: $1
just outputs the content remembered by the brackets in the pattern. $n generates a newline (just
as %SEARCH% does).
Finally header is the header string prepended to output.