Port of schuchert.wikispaces.com


FitNesse.PageHierarchyForTeamDevelopment

FitNesse.PageHierarchyForTeamDevelopment

Background

There are several ways to organize a team’s use of FitNesse. This document mentions one and describes a second one in some detail. The two models are the “FitNesse as an Editor” model and the “FitNesse Server” model.

The Models in a Nutshell

FitNesse as an Editor

There are several ways to layout pages using FitNesse. One mechanism is to keep FitNesseRoot checked into your favorite repository and developers simply check it out on their local machine. Updating a test involves the following steps:

This is a straightforward mechanism with a few issues:

However, these are minor nuisances. In many cases, the people writing acceptance tests in FitNesse are quite comfortable with such tools and the change frequency of acceptance tests is such that merge conflicts do not happen too often in practice.

The last bullet is both a strength and weakness. Forcing the machines to have similar configurations can actually remove problems over time. It also discourages one-off solutions as they will immediately break on other machines.

FitNesse Server

In this configuration, there is a master FitNesse server. People working on tests have a local installation of FitNesse with a page that makes a virtual link to the server pages. The server pages are shadowed on the local machine. People make updates remotely, making the changes immediately available. The FitNesse Server installation is configured to be backed up on a regular basis.

This second model is describe in more detail below.

Setting up the FitNesse Server Model

This model has a few characteristics:

Overview

The picture gives a high level view. In a nutshell:

On The Server

On A Developer Machine

When someone browses to the server machine and hits the test button, the environment settings are found on the server machine. When a developer browses to his/her machine and executes tests, the page hierarchy is different, so different settings are found and used for test execution.

A developer edits pages remotely rather than locally. The page is immediately updated on the server and picked up by other people. At the request of a colleague, I want to emphasize this:

Why? So their work is immediately shared. These are meant to be collaborative. If for some reason you want to have “passing” and “in progress” tests, there are several mechanisms to manage this:

In any case, test writers should be editing remotely.

Detailed Steps

This set of steps describes how to simulate this on a single machine to practice. The only change to the real configuration is that you need to physically install FitNesse on a different machine.

Setup Two FitNesse Servers

Create a location for the “server machine”.

java -jar fitnesse.jar -p 9080

Note that this both creates the FitNesseRoot directory and starts FitNesse listening on port 9080.

Create a location for the “developer machine”

java -jar fitnesse.jar -p 8080

Note that this both creates the FitNesseRoot directory and starts FitNesse listening on port 8080.

In this example I use 2 different ports because each executing FitNesse server needs to have its own port and I’m running FitNesse on the same machine twice.

The rest of this example uses a simulated project called “Dvr” for DigitalVideoRecorder.

Creating Server Page Hierarchy

Top Level Environment

Common Environment

!define TEST_SYSTEM {slim}
!path fitnesse.jar

!contents -R2 -g -p -f -h

Create a top-level suite page

While not strictly necessary, this top-level page will remain stable while the common environment page might change. It is reasonable to merge the common environment and top-level suite pages, this example keeps them separate.

Create a Common Setup

This SetUp page will apply to all children test pages that do not have SetUp pages. If you need to have multiple setup pages, you can use an import statement.

|import|
|com.om.fitnesseexample|

Create an Example Test

This is a simple test we’ll use to verify that things are working.

!|IsThisTheServer|
|server?|
|true|

Get Server Test Passing

Now you’ll create a single Eclipse workspace with two projects. One project will have code that will be executed on the server installation of FitNesse, the other will have code executed by the Developer installation of FitNesse.

package com.om.fitnesseexample;

public class IsThisTheServer {
  public boolean server() {
    return true;
  }
}

The server needs to know where to look for java classes. We will configure this on the server configuration page. By default, Eclipse will compile this and put the classes in /Users/schuchert/src/FitNesseLinkPageExample/server/bin. You might need to search for the top-level class directory.

!path /Users/schuchert/src/FitNesseLinkPageExample/server/bin

!contents -R2 -g -p -f -h

Setting up Developer Machine

The procedure is much the same for the developer machine, with a little less setup.

!path /Users/schuchert/src/FitNesseLinkPageExample/developer/bin

!contents

Notice that this class path is different, it points to a directory that does not currently exist. You’ll be creating that shortly.

Replicating Server Tests

You should see the classpath as well as a the pages from the server listed as children of this page.

Getting Developer Test Running but Failing

If you attempt to run the test, it will fail with yellow errors indicating that one or more classes could not be found. You’ll create a second Java project in your workspace.

package com.om.fitnesseexample;

public class IsThisTheServer {
  public boolean server() {
    return false;
  }
}

Notice that this is the same class and package, but a different implementation. What makes FitNesse select one fixture class versus the other is the !path statement on the local environment pages. (This is similar to what Michael Feathers calls a Link Seam.)

Verify that your test fails with a red error (indicating class found but assertion did not pass).

Congratulations

Good work, you:

Now you are ready to try this out in your development environment.

Final Note on Backups

With this configuration, you can simply schedule a backup of the FitNesseRoot directory on the server machine every so often to avoid losing tests.

Alternatively, and my preference, is to actually have the edits checked in to a source repository. However, if you do use the single server model, you will lose track of who made changes. This, as far as I can tell, is probably the biggest drawback to the approach. However, in practice I don’t see it as too much of an issue with teams that collaborate well.


Comments

" Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.