Software QA FYI - SQAFYI

Acceptance Testing with FitNesse: Documentation and Infrastructure

By: Michael Sorens

Contents
Documentation
Infrastructure
Differentiating Java from .NET
Include .NET-Equivalent References
Include .NET-Equivalent Using Statements
Let FitNesse Dynamically Index Your Sub-Pages
Allow Concurrent Test Access
Avoid Duplicating Setup or Teardown Code
Avoid Duplicating Any Other Code, Too
Moving, Renaming, or Deleting Tests


FitNesse is a wiki-based framework for writing acceptance tests for software systems. If you are not familiar with FitNesse, then you’ll find Part 1 of this series, 'Acceptance Testing With FitNesse, The Overview', useful because it walks through a complete .NET example from writing the test in your browser to writing the C# code-behind. Although FitNesse provides a rather nifty and user-friendly way to write acceptance tests in general there are, in practice, plenty of quirks and glitches to watch out for. This article, and the subsequent parts of this series, provides “tips from the trenches”, by which I mean an accumulation of tips collected from intensive daily use of FitNesse to alleviate or avoid many of those pain-points.

This article covers various issues with the documentation and infrastructure; subsequent parts will cover tips about such things as naming, debugging, control flow, layout, variables, comparisons, tracing and database. Documentation

FitNesse was originally designed for testing Java code, but it has since evolved to handle .NET code with the separate fitSharp component and does so pretty well. Database support came later with the DbFit component. Those two components, together with the base FitNesse component, all provide their own documentation with different styles, organization and comprehensiveness. As so often with software documentation, it can be a challenge to find the information you are looking for. Here then, is a collection of the most useful links within the documentation of FitNesse, fitSharp, and DbFit:

FitNesse User Guide (The starting point for all things FitNesse.)
FitNesse Quick Reference to formatting and executing FitNesse tests. (On your local installation, this will be located at http://localhost:port/FitNesse.UserGuide.QuickReferenceGuide.)
FitNesse Fixture Gallery and FitNesse Fit Table Styles (e.g. Column Fixture, Row Fixture, Comment Fixture, etc.)
FitNesse Special Pages (e.g. SetUp, TearDown, PageHeader, PageFooter, etc.)
FitSharp Fixture/Feature Gallery (e.g. Debug Fixture, Calculate Fixture, Cell Operators, etc.)
DbFit Fixture Gallery (e.g. Query Fixture, Insert Fixture, Execute Fixture, etc.)
DbFit Reference (This covers DbFit but it is not quite complete: for a variety of actual examples, download the complete FitNesse and DbFit package from the DbFit website, run it, then select .NET Acceptance Test and choose SqlServerTests. The direct URL on your own installation is ...
http://localhost:port/DbFit.AcceptanceTests.DotNetTests.SqlServerTests.
Test Driven .NET Development with FitNesse (This book is the next stepping stone, covering all things FitNesse-plus-.NET)

The first part of this series was just intended to help get you up to speed if you had never been exposed to FitNesse, so it is more tutorial than reference. This and subsequent parts, however, lean more towards reference than tutorial. The main FitNesse site provides some additional tutorial material—notably their One-Minute Description and Two-Minute Example, among other good learning material. Use the User Guide link above to see those.

Infrastructure
Differentiating Java from .NET
By default, FitNesse works for the Java environment. To work in a .NET environment you must download the fitSharp DLL and tell FitNesse to use that instead. Typically you do this on your root page—accessible from a link at the bottom of every FitNesse page (the address is http://localhost:port/root). Use the !define directive as follows:

!define COMMAND_PATTERN {%m -r fitnesse.fitserver.FitServer,fitsharp\fit.dll %p}
!define TEST_RUNNER {fitsharp\Runner.exe}
!define PATH_SEPARATOR {;}
variable defined: COMMAND_PATTERN=%m -r fitnesse.fitserver.FitServer,fitsharp\fit.dll %p variable defined: TEST_RUNNER=fitsharp\Runner.exe variable defined: PATH_SEPARATOR=;

References: Defining Common Actions, Customizing Test Execution, Using FitNesse Include .NET-Equivalent References

You must include references in FitNessse with the !path directive to access the namespaces and classes in a DLL.This is In much the same way as a Visual Studio project. You do not need to include either FitNesse, as this is handled by the JAR file you launched, or fitSharp, handled by the TEST_RUNNER definition described in the previous section. You would, however, include DbFit if you are using database fixtures as well as your custom DLLs:

!path fitsharp\dbfit.dll
!path fitsharp\dbfit.sqlserver.dll
!path Fixtures\CleanCodeFixtures.dll

classpath: fitsharp\dbfit.dll

classpath: fitsharp\dbfit.sqlserver.dll

classpath: Fixtures\CleanCodeFixtures.dll

Just as with the COMMAND_PATTERN and TEST_RUNNER in the previous section, you typically specify these on your root page, which is accessible from a link at the bottom of every FitNesse page (the address is http://localhost:port/root). You may optionally specify these from a suite configuration file instead. If you do, you do not need the %p in the COMMAND_PATTERN.

Reference: Defining Common Actions, Using FitNesse, Suite Configuration File Include .NET-Equivalent Using Statements

In much the same way that you optionally import namespaces with using statements in C# to obviate the need to use fully-qualified paths when referring to classes, you may do the same in FitNessse with the !import directive. Typically these go in a SuiteSetUp or SetUp page so they are inherited as needed, but you may use them directly on individual test pages as well.

A FitNesse import is analogous to a .NET using statement: you can then write unqualified class names in your code, making it more readable. At the left side of the table below, you see the use of an !import directive allowing the Echo fixture to be referenced without a fully-qualified namespace. At right, the namespace is required when the !import directive is not used.

Full article...


Other Resource

... to read more articles, visit http://sqa.fyicenter.com/art/

Acceptance Testing with FitNesse: Documentation and Infrastructure