Fitnesse - Test Table

> Test - Software, Framework and Library > Test - Fitnesse Framework

1 - About

A table (test table) is the basic statement of Fitnesse in order to defined test.

Advertising

3 - Format

The format is table dependent but they generally take the basic form of:

  • a constructor row (that defines the test class and the constructor argument)
  • a mapping row that define the data type (input or output) and maps the data to the method to be called
  • data rows that have some input, parameter cells which are followed by some Output cells.

This example from the getting started, a slim decision table:

|eg.Division                    | <-- The test class (Fixture)
|numerator|denominator|quotient?| <-- The method called (without ?, this is setter function, with a ?, the function returns value)
|10       |2          |5.0      | <-- The first row of data to set and to expect
|12.6     |3          |4.2      | <-- The second row of data to set and to expect
|22       |7          |~=3.14   |
|9        |3          |<5       |
|11       |2          |4<_<6    |
|100      |4          |33       |

where:

  • The vertical bars delimit table cells (tables are written by separating cells with the pipe symbol)
  • If you change “eg.Division” to any other name, you may need to add exclamation mark ! before. It is optional, and tells FitNesse not to apply any smart formatting to table contents (ie to avoid confusing FitNesse with WikiWords)
  • The fixture is the Java (or some other supported language) class that the engine will call to process the contents of the table.
  • eg.Division is the class to test where :
    • eg specifies a Java package (or other language namespace),
    • and Division specifies the actual class to be called.
  • the rows are processed from left to right,
  • the input values are headers without a question mark ?
  • the input values are passed to the corresponding fields using setter functions
  • the expected value are the header with a question mark (ie quotient?) and can be expressed with operators:
    • ~=3.14 - approximately equal
    • <5 - less than
    • 4<_<6 - between

After running the test:

  • In the green cells, we got back the expected values from our code.
  • A cell turns red when we get back a different value than what we expected. We also see two values: the expected value and the actual value.
  • A yellow cell, if an exception was thrown
Advertising

4 - List

5 - Management

5.1 - Creation

  • Manually
  • or Spreadsheet to Fitnesse.
    • copy the Excel table to the clipboard,
    • use the Spreadsheet to Fitnesse button on the Edit page

5.2 - Constructor

ConstructorArguments

|Decision:my decision table|constructor argument 1|constructor argument 2|
|...|

6 - Documentation / Reference

Advertising