Defining common actions

In addition to SetUp, you can also create a TearDown page that will be executed after each test. SuiteSetUp and SuiteTearDown pages, if they exist, are executed when the entire suite starts and ends respectively. You can define common content that is not test related with PageHeader and PageFooter special pages in each subwiki. The suite page can also contain common path definitions. In addition, there is a special root page that defines global definitions for the entire system. So there are quite a few options for defining common content for several pages. Here are a few simple guidelines on what to use and when:

  • Put common HTML content like documentation links into PageHeader and PageFooter, as they are pasted directly into the page code. SetUp and TearDown are not good for this because they will have a border when displayed on screen.

  • If you use FitNesse only for .NET testing, add global path and runner definitions for including basic FIT libraries and setting up a .NET 2 runner to /root.

  • Put project-specific DLL paths in the main test suite page. FitNesse looks for path definitions up the hierarchy, so this ensures that correct DLLs will be loaded for all the tests.

  • Put package includes and initialisations such as the setup of a database connection pool in either SuiteSetUp or SetUp. The difference is that SetUp is executed before each test, and SuiteSetUp is executed once only for the entire test suite. Also, in FitNesse releases before 20070619 SuiteSetUp does not run when you execute individual test pages from a suite.

  • Add actions that have to be executed once and only once for the entire suite run to SuiteSetUp.

  • Extract utility tables that perform common processing or tests into pages outside the test hierarchy, and then include them in tests with the !include directive.