FitNesse: Get FIT test column names in an array

395 Views Asked by At

Is there a way to grab the column names for the following FIT test into a list or array?

This is required for a fixture where the number of columns is not known beforehand.

E.g. in the example below there are just 2 columns but this can vary.

|myfixture    |
|col1  |Col2  |
|value1|value2|
|value3|value4|

There is a need to generate a dynamic list of columns.

2

There are 2 best solutions below

0
On

You can access the column headings when you extend Fixture:

public class MyFixture extends Fixture {
    public override void doRows(Parse rows) {
        for (Parse cell = rows.Parts; cell != null; cell = cell.More) {
            // cell iterates over the column heading cells
        }
    }
}
0
On

I created my own subclass of ColumnFixture that stores each row's input columns in a Map. For each row the column names are used as the Map's keys.

Clone https://github.com/fhoeben/hsac-fitnesse-fixtures and take a look at nl.hsac.fitnesse.fixture.fit.MapColumnFixture. If your Fixture subclasses this you can get the headers as getCurrentRowValues().keySet().