Skip to content
This repository

A FitNesse fixture for testing REST services

README.md

RestFixture: A FitNesse fixture for testing REST services

The RestFixture is a FitNesse (http://fitnesse.org) fixture that allows developers and/or product owners to write test fixtures for REST services with simplicity in mind. The idea is to write tests that are self documenting and easy to write and read, without the need to write Java code.

The fixture allows test writers to express tests as actions (any of the allowed HTTP methods) to operate on resource URIs and express expectations on the content of the return code, headers and body. All without writing one single line of Java code.

And it also works as a living/executable documentation of the API.

The fixture can be used with both Fit (FitRestFixture) and Slim (Table:Rest Fixture) runners.

Overview:

Documentation:

http://github.com/smartrics/RestFixtureLiveDoc

Build: Releases from 2.1 onwards

To build RestFixture install Maven and execute

mvn clean package

Once the build completes, the directory target contains:

  • smartrics-RestFixture-<version>.jar : the RestFixture jar
  • dependencies/ : all the RestFixture dependencies (excluding a Logging framework implementation. See below for details)
  • smartrics-RestFixture-<version>-bin.zip: a bundle the RestFixture and all dependencies.

If the build fails because smartrics-RestClient can't be found, check the pom.xml file and make sure the repository sonatype-releases-restclient is enabled.

Build: Releases up to 2.0

To build RestFixture add a property file in the properties directory named .properties by copying and customising build.properties if necessary.

Use

ant

or

ant full

to run the default target (this will build the Rest Fixture, start a local instance of FitNesse on port 7070 and run the fitnesse tests in src/test/cat.

You can also pass a build properties file to ant with

ant -Dproperties=.properties

If it all succeeds a distribution of the RestFixture is available in dist/ alongside with the latest documentation. Reports of tests and metrics are available in build/reports

The (missing!) logger framework dependency

The RestFixture uses slf4j-api; if no logger implementation is provided slf4j defaults to nop binding. Please download and add to the classpath your binding of choice (and the respective configuration file).

The current version is slf4j-api-1.6.6, hence download the matching version of the binding implementation.

Check http://www.slf4j.org/ for more details.

Install

To use the RestFixture, simply add RestFixture-.jar to your FitNesse tests classpath, alongside its dependencies. Dependencies are available in the directory target/dependencies.

For example, let's assume that you have succesfully built the RestFixture in C:/RestFixture

  1. Download a binding logger implementation for slf4j and copy it into C:/slf4j-simple/slf4j-simple-1.6.6.jar. Download it from http://repo2.maven.org/maven2/org/slf4j/slf4j-simple/1.6.6/slf4j-simple-1.6.6.jar
  2. Start FitNesse; let's assume that fitnesse is now running on port 8090)
  3. Go to http://localhost:8090/RestFixtureInstallTest to create a new test page
  4. Type the following:
!define TEST_SYSTEM {slim}

!path C:/RestFixture/target/dependencies/*
!path C:/RestFixture/target/smartrics-RestFixture-&ltver>.jar
!path C:/slf4j-simple/slf4j-simple-1.6.6.jar

|Table:smartrics.rest.fitnesse.fixture.RestFixture | http://localhost:8090 |
| GET | /RestFixtureInstallTest?rss | | | //title[text()='RestFixtureInstallTest']|
  1. Execute the test. If it passes, you have succesfully installed the RestFixture. You'll also know how to reference it's jar and dependencies.
Something went wrong with that request. Please try again.