The Fixture Gallery is also available as a PDF document and a live FitNesse wiki. See http://gojko.net/fitnesse/fixturegallery for more information.
Previous page: DoFixture Next page: ArrayFixture Parent page: FitLibrary Fixtures

SequenceFixture

SequenceFixture is very similar to DoFixture and has almost the same features -- in fact the only difference between those two is the naming convention for methods. Instead of using odd cells to construct a method name, SequenceFixture takes the first cell in each row as the method name, and all other cells as arguments (if there are no keywords to modify the row functionality). All DoFixture keywords are supported in SequenceFixture too, as well as the flow mode (see Flow Mode ) and domain object wrapping (see System under test).

Table Format

The table format is the same as for DoFixture (see DoFixture), with the difference in method naming.

!|SequenceFixtureTest|
|fill|10|x|
|check|char at|4|x|
|set list|A,B,C,D|
|check|char at|2|C|

Fixture class

The fixture class should extend fitlibrary.SequenceFixture. Declare public methods for all verifications and actions by taking the first cells as the method name, and using all other cells as arguments.

Java Source Code

package info.fitnesse.fixturegallery;
import java.util.Arrays;
import fitlibrary.SequenceFixture;

public class SequenceFixtureTest extends SequenceFixture{
	public String letters;
	public void fill(int count,char c){
		char[] arr=new char[count];
		Arrays.fill(arr,c);
		letters=new String(arr);
	}
	public void setList(char[] array){
		letters=new String(array);
	}
	public char charAt(int position){
		return letters.charAt(position);
	}	
}

.NET Source Code

using System;

namespace info.fitnesse.fixturegallery
{
    public class SequenceFixtureTest : fitlibrary.SequenceFixture
    {
        private String contents;
        public void Fill(int howmany, String what)
        {
            contents = "";
            for (int i = 0; i < howmany; i++)
            {
                contents = contents + what;
            }
        }
        public void SetList(String[] strings)
        {
            contents = "";
            foreach (String s in strings)
            {
                contents = contents + s;
            }
        }
        public char CharAt(int index)
        {
            return contents[index];
        }
    }
}

Usage

SequenceFixture has all the flexibility and power of DoFixture, but without the silly method names. It is most useful for more technical workflow tests, especially to directly map FitNesse tables to existing business domain services (see System under test).

Previous page: DoFixture Next page: ArrayFixture Parent page: FitLibrary Fixtures


Personal Tools