List Fixture allows Lists to be defined and manipulated in the wiki. It is usable both in script tables and dynamic decision tables.
Furthermore it also allows us to ensure Slim show lists as numbered items, instead of comma separated between square brackets (i.e. '[' and ']').
Lists in a Script
Here we manipulate lists using script tables[?].script | list fixture | ||
add | Fried | ||
add | github@hsac.nl | ||
check | value at | 0 | Fried |
check | size | 2 | |
set value | Ivan | at | 4 |
check | size | 5 | |
check | value at | 2 | null |
check | value at | 3 | null |
check | value at | 4 | Ivan |
check | value at | 1 | github@hsac.nl |
set value | Jan | at | 1 |
check | value at | 1 | Jan |
ensure | element | Ivan | is present |
check | index of | Ivan | 4 |
check | index of | Klaas | -1 |
$list1<-[[Fried, Jan, null, null, Ivan]] | copy list |
Showing Lists as Numbered Items
As seen in the table above Slim's default behavior is to show lists using Java's toString() notation, comma separated between square brackets.By invoking ListFixture's display lists numbered method we instruct Slim to show lists as HTML ordered lists.
This could also be achieved directly in Java code by invoking nl.hsac.fitnesse.slim.converter.NumberedListConverter.register().
script | list fixture | ||
display lists numbered | |||
add | Fried | ||
set value | Jan | at | 1 |
$list1<-[
|
copy list |
List may be nested
script | list fixture |
add | $list1->[
|
add | $list1->[
|
copy values from | $list1->[
|
$list2<-[
|
copy list |
Define a List using Dynamic Decision Table
This examples show usage of the fixture in a dynamic decision table[?].Here we define two lists (and store them in Slim variables) using a dynamic decision table. Any output column (header name ending on '?') will receive a copy of the list defined.
ddt: list fixture | ||||
0 | 1 | 3 | 4 | list? |
Jan | github@hsac.nl | Karel | $list3<-[
|
|
Karel | Piet | Milk | $list4<-[
|
List as Argument
We don't use lists defined in the current fixture instance, but supply the lists to work on in the rows to the script.script | list fixture | ||||
check | value at | 1 | in | $list3->[
|
github@hsac.nl |
check | size of | $list3->[
|
5 | ||
check | value at | 2 | in | $list4->[
|
null |
check | value at | 3 | in | $list4->[
|
BLANK |
set value | Ivan | at | 3 | in | $list4->[
|
check | value at | 3 | in | $list4->[
|
Ivan |
ensure | element | Ivan | is present in | $list4->[
|
|
check | index of | Ivan | in | $list4->[
|
3 |
copy values from | $list1->[
|
to | $list4->[
|
||
check | index of | Fried | in | $list4->[
|
5 |