Вы находитесь на странице: 1из 5

What is FitNesse?

FitNesse is a software development collaboration tool

Great software requires collaboration and communication. FitNesse is a tool for enhancing collaboration
in software development.

FitNesse enables customers, testers, and programmers to learn what their software should do, and to
automatically compare that to what it actually does do. It compares customers' expectations to actual
results.

It's an invaluable way to collaborate on complicated problems (and get them right) early in development.

(The above description is adapted from James Shore's description of Ward Cunningham's Fit
Framework, which is one of the test systems upon which FitNesse depends.)

FitNesse is a software testing tool.

From another perspective, FitNesse is a lightweight, open-source framework that makes it easy for
software teams to:

 Collaboratively define Acceptance Tests -- web pages containing simple tables of inputs
and expected outputs.

 Run those tests and see the results (see Two Minute Example).

FitNesse is a wiki.

 You can easily create and edit pages. (See Editing Pages.)

FitNesse is a web server.

 It requires no configuration or setup.

 Just run it and then direct your browser to the machine where it is running (see
Downloading and Installing).

--> Want a quick introduction? Check out the Two Minute Example.
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.0
12.6 3 4.2
22 7 ~=3.14
9 3 <5
11 2 4<_<6
100 4 33

This style of FitNesse test table is called a Decision Table, 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.0" 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!

Notice also the comparisons. 22/7 is approximately equal (~=) to 3.14. 9/3 is less than 5. 11/2 is between
4 and 6.

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 (with some omissions) 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.

Note also that if you change "eg.Division" to any other name, you may need to use a ! before the fixture
to avoid confusing FitNesse with WikiWords (see MarkupTable)

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.

Editing and Creating Pages in FitNesse

FitNesse is a wiki web server. Before you can begin CreatingTestTables, you need to know a bit about
how a wiki works.

A wiki allows any authorized user to make changes to any edit-enabled page, or to create new pages,
simply by using their Web browser. If you are working with a copy of FitNesse on your own machine,
you are probably authorized to make such changes. (If you have not yet installed FitNesse on your own
machine, it's easy do to. You can read about it on DownloadingAndInstallingFitNesse.)

Editing a Page

Once you are on a page your want to change, hit the Edit button in the upper left. (If the button does not
appear, then the page is not edit-enabled.)

A new window will pop up with an edit frame containing the markup language of the current page. You
specify formatting using a simple markup language. Simply make your changes to the page and hit the
Save button. Voila! Your changes appear on the page.

Creating New Pages

Every FitNesse page has a name in so-called camel-case format, in which the first letter is upper-case,
and at least one other letter in the word is upper-case. The name of this page, EditingFitNessePages, is
an example. This convention makes it truly easy to create new pages and links to those pages.

When you edit an existing page and insert a new camel-case word, such as ThisHereNewPage, and then
click the Save button, FitNesse interprets that to be a link to a new, as-yet-uncreated page. It indicates
this to you by putting a question mark at the end of the name.

If you then click on that question mark, FitNesse displays an edit frame, enabling you to put something
on that new page. If you type anything at all in there and click Save, your new page is created, and the
link to it is enabled on the originating page.

Try Creating a New Page with a Link Back to This One

Try it yourself. Click on the question mark at the end of this word: ThisHereNewPageExample Put
something on the page, click the Save button, and then return here. A good thing to put on the new page
is the word EditingFitNessePages, so that you can return to this page easily!

A Few Formatting Examples


The wiki markup language is fairly powerful. Two see how we accomplished each of the formatting
examples below, you can simply click the Edit button and check it out for yourself.

You can make text bold by putting three single quotes (ticks) on each side of it (e.g., '''make text bold''').
You can make text itallic by putting two ticks on each side of it (e.g., ''make text itallic'').

You can center a line by prefixing it with !c

This line is centered.

You can make a horizontal rule by using four or more dashes.


So ---- becomes

Вам также может понравиться