Main Page

From ServiceFixture

Jump to: navigation, search


What is ServiceFixture

ServiceFixture is a fixture library built on top of FIT/FitNesse which enables FitNesse to be the integration test and software collaboration platform for service oriented and distributed systems. These systems usually expose stateless services, such as web service (SOAP or REST), ejb and POJO etc, to its internal or external clients, and complex domain objects are always involved in the service interfaces.

It is difficult to leverage FitNesse for these systems due to the fact that it is not trivial to represent complex domain objects in FIT test table, and hence it would require constant fixture development efforts to support the integration test. ServiceFixture is designed to fill this gap.

ServiceFixture uses expression language to represent domain objects, verify and display the response in FIT test table. Every ServiceFixture test is basically a method invocation to a stateless service. The test starts with setting up the input data, then invoking the service operation, and then checking the response.

Because the ServiceFixture is very generic, to setup ServiceFixture and FitNesse for a project, you only need to write a ServiceFixture extension to encapsulate the invocation logic once, which is pretty trivial. No more fixture development is needed after that. It also provides template creator integrated with FitNesse to make tester's life a lot easier too.

ServiceFixture also provides database service fixtures(SelectFixture and UpdateFixture) which can be used to access databases directly from FitNesse test scripts. See Tutorial for more details.


  • Supports representation of complex domain objects automatically using expression language.
  • Generic interface that eliminates constant fixture development efforts.
  • Supports both positive and negative tests.
  • Provides built-in expressions that can be used to generage dynamic test data.
  • Supports all java primitive types and wrapper classes.
  • Supports Java5 Enum type as well as Enumeration pattern.
  • Supports java.util.Date, java.sql.Date, java.util.Calendar and javax.xml.datatype.XMLGregorianCalendar
  • Supports collections such as java.util.List, java.util.Set and Java array type.
  • Provides extension points for custom converter, token(expression used to generate dynamic test data), comparator and collection type.
  • Provides database service fixtures for database access from FitNesse test scripts.
  • Provides template creator that can be used to generate test table template with the complex object graph automatically.
  • Provides a WinNTAuthencator that allows users of FitNesse to log on using existing NT accounts.
  • Provides a TestRunner that can be used to run FitNesse tests from command line or build tools. Also comes with a Maven 1.1 Plugin that uses the TestRunner.

Now here are some examples.

Learn by Example

Positive Test Example

Here is a sample positive FitNesse test page source:

'''Create a new customer.'''

|check|response != null|true|

'''Get the customer, and make sure the customer was created properly.'''

|check|response != null|true|

Above test page tests createCustomer and getCustomer operations of a customer service, set rows prepare the complex domain objects as the request data, invoke row makes the call to the service, and check rows verify the response data, key row basically stores the request and response for the test table so that its request and response can be used by subsequent test tables. As you would realize, ServiceFixture uses expression language to prepare the request and verify the response.

ServiceFixture also provides built-in functions to generate dynamic data, like function used in above test tables,${}, generates a random email address.

Positive Test Screenshots

Here is screenshot of above test page:


Test result screenshot of above test page:


Note that the evaluated expression values are displayed in the test result page.

Negative Test Example

ServiceFixture also supports negative tests. Here is a sample negative FitNesse test page source:

'''The email address of the customer is validated by customer service. If the email address is invalid, !-net.servicefixture.sample.ValidationException-! would be thrown, this test verifies that.'''

|check|exception.message|Invalid Email Address:InValidEmail|

This test passes an invalid email address to createCustomer service call, and expects service to throw an exception back, and the exception class should be net.servicefixture.sample.ValidationException. It checks the exception message as well.

Negative Test Screenshots

Screenshot of above negative test page:


Screenshot of above negative test result page:


Getting Started

A great way to start is to visit the Tutorial page, and download the servicefixture and fitnesse bundle here download.

  • Other helpful links;

  • Help Forum
  • Report an Issue or Feature Request


Personal tools