FitNesse. UserGuide.
CreatingTestTables [add child]

Getting Test Tables Onto the Page

As we have seen FitNesse expresses AcceptanceTests as tables of input data and expected output data. (If you have not done so, you should probably check out the example table tutorial in the TwoMinuteExample. You should then check out the wiki page-editing tutorial on EditingFitNessePages.) Yet again, let's look at our test table for testing the division function of a calculator application:

eg.Division
numerator denominator quotient?
10 2 5
12.6 3 4.2
100 4 33

So how do we get this table on to the page? Well the wiki markup language that defines the above table looks like this:

|eg.Division|
|numerator|denominator|quotient?|
|10 |2 |5 |
|12.6 |3 |4.2 |
|100 |4 |33 |

Typing it In By Hand

We can pretty easily type in the above markup code for our Division table by hand in the page editing window. The vertical bars (|) delimit cells within rows. As long as you have the right number of vertical bars between data elements, FitNesse will correctly format your table for you. For small tables that will not change frequently, that's a perfectly reasonable way to do it.

Using a Spreadsheet to Create Tables

Let's face it: a simple text-editing frame (such as the FitNesse edit frame) is not the best tool in the world for manipulating tabular representations of data. It's not especially easy to copy and paste rows or columns, move rows or collumns, etc. That's the sort of thing that spreadsheets are great at. When you work with lots of FitNesse tables, particularly large ones, it's great to be able to work in a spreadsheet like Excel to get the table just the way you want it, then copy it over to FitNesse, formatted properly using the wiki markup language. Fortunately, FitNesse makes this easy to do.

Spreadsheet Example


Let's say you are editing your Division table in Excel, like so:


...and you would like to put that same table on a FitNesse page? Follow these steps:

eg.Division
numerator denominator quotient?
10 2 5
12.6 3 4.2
100 4 33

Voila! FitNesse reformats the table (and any other table on the page) with the proper wiki markup delimiters:

eg.Division
numerator denominator quotient?
10 2 5
12.6 3 4.2
100 4 33

Note: This is best done one table at a time, one page at a time. Furthermore, the table must have at least two columns. When you click the Spreadsheet to FitNesse button, FitNesse attempts to format everything on the page that might be a table.

Copying Tables From FitNesse to the Spreadsheet

You can also take an existing FitNesse table, select it, and click the FitNesse to Spreadsheet button to get it back into non-wiki markup language format. You can then easily paste it back into the spreadsheet application.

Learning More

If you are interested in the fixture code that makes it possible to run test tables, check out FixtureCode. If you want to learn what the different styles of test tables are and how to apply them, check out TestTableStyles.