Wednesday, March 18, 2009

Fitnesse Acceptance Testing Framework

Introduction:

FitNesse is a Wiki built on top of Fit framework which is used for automating Acceptance test cases. FitNesse enables customers, testers and programmers to learn what their software should do, and to automatically compare that to what it actually does do. In very simple terms, it compares customer's expectations to actual results. This tool is built on top of FIT framework. Fit and FitNesse, both believe that great software requires collaboration and communication. These tools enhance the collaboration between customer, testers and programmers by providing a single platform for communication. FitNesse can be seen as a software testing tool, a WIKI or a web server.

Why do we need FitNesse?
Unit testing is a well-known practice that helps developers validate the functionality of components and identify bugs early when they are easy to fix. By leveraging frameworks like JUnit, Nnit tests are very easy to write and execute, and therefore provide very rapid feedback about the status of the system. The problem with unit tests by themselves is that they test such fine-grained pieces of functionality that it is easy to end up with gaps in coverage for the system overall. And, because unit tests are strictly a developer tool, any miscommunication or misunderstanding about requirements cannot be caught, and the business users have no visibility into these tests.
Acceptance tests, on the other hand, test coarse-grained services within the application, which complements the coverage gained by unit tests. The same people who write acceptance tests also generally write and maintain the requirements; therefore, the tests usually reflect the requirements more accurately. Despite the benefits of writing and running acceptance tests early, this type of testing is rarely done until late in the project's life cycle. Why? The problem with these tests is that they are generally very expensive to write and automate. The people defining the acceptance criteria, the customers or business analysts as their proxies, usually aren't programmers and don't have the skills or time necessary to write effective automated test scripts.

The Framework for Integrated Test (Fit) and FitNesse address these issues. Fit is an open source acceptance testing framework, and FitNesse is a wiki-based test execution engine that allows users to write, edit, and run Fit tests over the web. Together these tools enable developers and users to express acceptance tests in a tabular format and execute them from a simple web interface. Using Fit and FitNesse, teams can reduce drastically the effort required to create automated acceptance tests, all while increasing the accessibility of the tests and their results.


Advantages of FitNesse:

Ÿ Advantage of FIT and FitNesse for acceptance testing is that they use an approach that enables users and user representatives to write acceptance tests via a spreadsheet-like approach. This feature decouples the creation of acceptance test suites from dependence on developers.
Ÿ FitNesse tests can give us feature feedback very early in the project. In fact, the tests ought to be written first, so programmers can code to the tests.
Ÿ FitNesse tests can give us feature feedback very frequently. They can be run manually or automatically by anyone with web access to the server, as frequently as required. Every week, every day, every hour in a crunch.
Ÿ FitNesse tests are deterministic: they either run green or red. If they run green for a given requirement, either the requirement is done and we move on to others, or the set of tests is not yet exactly right, in which case we refine them. Either way, we are successively refining the system in an orderly way. With each new test running green, we can all see the system getting better, more valuable, closer to what we need.
Ÿ Test data in FitNesse is developed either by the customers or by development or quality team with the help of customer representative. Since this data is developed from the user stories and is specified in a deterministic manner, it ensures that expectation from the system is clear to everyone.
Ÿ Being based on example data, FitNesse tests exercise more paths through the business logic. When you use FitNesse, you run less risk of missing important features or functional behavior.
Ÿ Only automated acceptance testing (such as that provided by FitNesse) enables you to measure Running, Tested Features, which is a key metric for measuring software project progress and success.
Ÿ FitNesse automated acceptance testing is a natural complement to xUnit (NUnit) based unit testing. The former helps you build the right code, while the latter helps you build the code right. Consider using both tools.
Ÿ Fit and FitNesse can be used to easily create a suite of automated acceptance tests that can be shared and maintained by an entire team. The libraries provided by Fit and FitNesse are very extensible and allow to create fixtures that can execute any table as a test.
Ÿ It also enables a mixture of documentation and testing that can result in testing documents that also provide considerable insight into how systems should work.Such test suites can really help when the time comes to produce formal documentation and training materials.
Ÿ Fitnesse can be used as a tool to support the user acceptance test driven development process for agile development method such as ExtremeProgramming.Planning and feedback loops in Extreme Programming (XP) with the time frames of the multiple loops.




How it is implemented?
Tables are the crux of FitNesse. Acceptance tests in FitNesse are defined in the tabular format. This deterministic tabular format is understood by the FIT library. These tests or tables are defined in terms of input and expected output data. In order to read those tables and test the application under test with the data used in these tables Fixture code need to be write. Fixture Code is a bridge between the table and
application under test. It understands the language of table and uses this information to exercise the functionality of application.



FitNesse Test System

A FitNesse test is composed of three basic elements: the test page, the test fixture, and the execution engine. The first component, the test page, is simply a wiki page that contains one or more test tables in addition to any no executable tables or text that describe the test or requirements in more detail. When FitNesse executes a test page, the test tables are run sequentially, which means that not only can you put multiple test tables on a given page but you can also have subsequent test tables rely on the state that was set up by previous tables.

The second component, the test fixture, is a class that interprets the information provided in a table and uses it to exercise the application. The examples discussed here demonstrate using Java to write the fixture code; however, there is also a version of FitNesse included in the main distribution that runs on the .NET framework, and it would be relatively trivial to port any of these examples to C# or VB.Net.

All fixture classes ultimately extend the base Fixture class provided in the FitNesse libraries. In addition to the base Fixture class there are a number of fixture subclasses that can be used as extension points that provide additional functionality and make writing the fixtures for common types of test tables very easy. The vast majority of test fixtures that the average team must write will extend from one of these subclasses.

The execution engine is the third component that is provided by the FitNesse libraries and is completely abstracted away from the users of the tool.

Just two steps are required to automate user acceptance tests using FIT:
1. Express a test case in the form of a FIT table
2. Write the code in Java or C#, called a fixture, that bridges the test case and system under test.

No comments:

Post a Comment