Action Fixture: Testing Sequences of Events


Sometimes the software behavior you are testing is inherently sequential: a series of events occur in a prescribed order. The Action Fixture style of test table (and FixtureCode) make it easy to write and run tests for such sequences of events. The metaphor for this fixture is a simple control panel:


For example, let's write a test for a simple counter.

Action Fixture.
start fitnesse.fixtures.CountFixture
check counter 0
press count
check counter 1
press count
check counter 2
enter counter 5
press count
check counter 6

Many kinds of event sequences can be boiled down to sets of these simple actions: entering, pressing, and checking. This style of table is often used, for example, to check sequences of user interface events.

To see the FixtureCode for this example, check out Action Fixture Code.

Seeing How Long Action Fixture Actions Take: TimedActionFixture


You can used TimedActionFixture if you want to see visual feedback on how long certain functions take to execute. (Technical note: This is strictly a matter of making sure that the FixtureCode for your table extends TimedActionFixture instead of Action Fixture.) Here is a version of our counter example that uses TimedActionFixture:

fit.TimedActionFixture
start fitnesse.fixtures.DelayedCountFixture
check counter 0
press count
check counter 1
press count
check counter 2
enter counter 5
press count
check counter 6

This DelayedCountFixture example simply adds a random delay to the count function.

TimedActionFixture does not give you a means of testing the time or the split. It simply displays them for visual inspection. Also note that the Timed Action Fixture does not report any delays that are less than one second. We don't know why Ward (inventor of the FitFramework) decided to impose this lower limit. Perhaps he'll remove it one day.

Learning More

To see an example of the fixture code for the Action Fixture test table style, check out Action Fixture Code. Also check out the other Test Table Styles.