Why another tutorial on installing and using FitNesse with .Net? Well, because I had a lot of trouble installing and using FitNesse with .Net. That may be an issue with the existing tutorials, or, it be an issue with me. Hopefully with these posts I can spare you some of the pain I encountered.
First things first. The source for all things FitNesse is here. There you’ll find lots of tutorials, samples and other useful info. In fact, if you stick at it you’ll get up and running using just the information on that site, but if you’re in any way like me you may find you slip off the happy path a few times. That’s where the tutorial you’re reading comes in.
Before you wrap your head around FitNesse, it helps to have an understanding of where it came from. The Framework for Integrated Testing (FIT) was developed by Ward Cunningham. The origins of FIT go back to a project where Cunningham discovered that he could allow users to enter test scenarios into a spreadsheet, and with a bit of coding he could make those test scenarios execute against the project code.
FIT is a publicly distributable version of that idea. Requirements can be written in a standard word document. Specific “examples” or “Test Cases” are created as Tables, and FIT enables us to hook that document up to executable code, run the tests and actually insert the results back into the Word Document.
FitNesse takes this notion a step further and provides a self contained Wiki complete with it’s own web server. Requirements can be entered into the Wiki or edited by anyone with access. A number of styles of tables give a means of demonstrating requirements using Sample Data. Like FIT, the FitNesse wiki can be “run” against our code base, and the results of tests inserted back into the Wiki.
Fit and Slim
Originally FitNesse used Fit as a means of hooking the tests (in the Wiki) up to executable code. Later the developers of FitNesse set about replacing Fit. The result was Slim. While you can still use FIT with FitNesse, I will focus on Slim, I think it’s an improvement on FIT and works better with .Net. There is a discussion of Fit and Slim here.
FitNess in Action
So, enough waffle, what does FitNesse look like in practice? The following screenshot shows a Decision Table, just waiting to be run. A Decision Table is one of a number of different types of tables that Slim provides as a means of illustrating requirements through tests.
We’ll get to what all of this means in due course, but for now, it’s a table with three inputs and an expected Result. The eagle eyed among you will notice that one of those examples looks like it’s expecting the wrong result. When we run our tests that should give us something worthwhile to look at.
Take a look at the buttons, they all do interesting things, but for now we’re just interested in the ‘Test’ button. If we click it, our FitNesse tests spring to life, execute themselves against our code base, fill in the results in our table, and highlight the passes and fails in green and read. Or to say it more simply with a picture…this happens…
Notice that one of the tests turns red. Dividing 6 by 3 doesn’t give 3. This isn’t highlighting a bug in the code, it’s highlighting a bug in the test, which can and does also happen from time to time. The point here is that when our expectations aren’t met, we’re told about it and can figure out whether it’s the code or the expectation that’s wrong.
What just happened?
How did the table know where to find our code and execute it?
How does it communicate with our code? How does it pass parameters and getting back results? What’s that text above the test table?
These and many more questions will be answered during this series of posts. I hope you’ll stay with me. Next up, we install FitNesse and a few more bits and pieces that we need to make it play nice with .Net languages like C#.
Fit Tables and Slim Tables
Before I close this post let me return to that issue of Fit vs Slim once more. A big practical difference between the two is the types of tables we can use to define tests. In the example above we used a Decision Table which is a Slim. The Equivalent Fit table is known as a ColumnFixture.
We’ll be using the Slim tables in these posts, but it’s worth being aware of Fit in case you see any examples of Fit tables.