FitNesse.
TwoMinuteExample [add child]
A One-Minute Description

An Example FitNesse Test

If you were testing the division function of a calculator application, you might like to see some examples working. You might want to see what you get back if you ask it to divide 10 by 2. (You might be hoping for a 5!)

In FitNesse, tests are expressed as tables of input data and expected output data. Here is one way to specify a few division tests in FitNesse:

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

In this style of FitNesse test table (ColumnFixture), each row represents a complete scenario of example inputs and outputs. Here, the "numerator" and "denominator" columns are for inputs, and the question mark in the "quotient?" column tells FitNesse that this is our column of expected outputs. Notice our "10/2 = 5" scenario. Try reading it as a question: "If I give you a numerator of 10 and denominator of 2, do I get back a 5?"

Running our test table: Click the Test button

Before we do another thing, let's run this test table. See the little blue and white Test button in the upper-left, just below the FitNesse logo? Click it and see what happens.

Ah, color! In the green cells, we got back the expected values from our code. When we divided 10 by 2, we expected and got back 5. When we divided 12.6 by 3, we expected and got back 4.2.

What about red? 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. Above we expected 33 back when we divided 100 by 4, but we got back 25. Ah, a flaw in our test table. That happens!

Creating the Table

How did we put that test table on this page in the first place? Well, we used FitNesse itself to do it!

FitNesse is a wiki, which is a style of web server that allows any visitor to make any edits, including changing existing pages and creating new pages. A simple markup language lets you easily create headings, make text bold, underline, and italic, create bulleted lists, and do other kinds of simple formatting. You can read more about it on EditingFitNessePages.

Once you download FitNesse to your own computer, you can edit any page simply by clicking on the Edit button on the left (just below the Test button). If you are reading this page on your own copy of FitNesse on your own machine, you can click the Edit button and see for yourself. (To learn more, see DownloadingAndInstallingFitNesse.)

The wiki markup for our table above looks like this:

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

The vertical bars delimit table cells. For this table, there is not much more too it than that. You don't have to line up the vertical bars this way; we just do it to make it easier to read.

Note that if you don't like mucking about with a markup language at all, you can create your test tables in a spreadsheet such as Excel, copy them to the clipboard, and use the Spreadsheet to Fitnesse button on the Edit page to have FitNesse format your table properly for you.

Organizing Tests

FitNesse test tables live on test pages (such as this one). There are several TestTableStyles. As your sets of test pages grows, you can organize them into hierarchical TestSuites.

Learning More

You Have Choices!

How shall you spend the next few minutes? It's up to you.

More Technical Detail...

If you are more interested in learning how to create the code that makes test tables work, see FixtureCode. If you want to start diving into installing and running FitNesse, check out DownloadingAndInstallingFitNesse.

More Useage Detail...

If you are more interested in why and how to get teams to use FitNesse, see AcceptanceTests. If you want to learn how to create and run FitNesse tests, check out EditingFitNessePages, CreatingTestTables, and TestTableStyles.

Or Take Your Own Path

Finally, if you want to zoom back out and look at all of the FitNesse topics, check out the table of contents on the UserGuide.

IsmetKahraman[?]
SamiKuzey[?]