Application Driven Testing of Drools with Fitnesse – part 1


Other Posts in this Series

Application Driven Testing of Drools with Fitnesse – part 2

Overview

Just as we can use JUnit as an integral part of Test Driven Development (TDD), we can also use Fitnesse as an integral part of Application Test Driven Development.

What does Fitnesse give us

Fitnesse provides a Wiki front end that can be used by Business Analysts and End Users (Customers) alike to provide Application Test Inputs to the System, Expected Outputs, and then execute the Java application / code you are interested in and test the actual outputs against the expected outputs.

Like JUnit, Fitnesse can run suites of tests and provides a comprehensive log of the results.

In this Post

In this first post, we will download Eclipse, and create a simple Maven project which includes the Fitnesse artifact and Drools 5.6.0 (we will move to Drools 6.0 later).  We will then launch Fitnesse from within Eclipse and see our page running.

Off We Go

Install JavaSE

Java SE can be found at http://www.oracle.com/technetwork/java/javase/downloads/index.html.  I’ve installed Java version 1.7.x, but I will configure Maven to run at version 1.6 for Drools 5.6.

Download Eclipse

Navigate to http://www.eclipse.org/downloads/ and download the Eclipse IDE for JEE Developers  for your Operating System.  I am running on OSX so have downloaded the Mac OSX 64-bit version.

Create a new Maven Project

Open Eclipse and create a new Maven Project

  • File -> New -> Project
  • Maven Project
  • Create a Simple Project
  • Group Id: com.skills421.tddrools
  • Artifact Id: FitnesseEIS

Edit the pom.xml as follows:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.skills421.tddrools</groupId>
<artifactId>FitnesseEIS</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<drools-version>5.6.0.Final</drools-version>
<fitnesse-version>20131110</fitnesse-version>
<junit-version>4.11</junit-version>
<log4j-version>1.2.17</log4j-version>
</properties>
<dependencies>
<!-- Drools -->
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
<version>${drools-version}</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>knowledge-api</artifactId>
<version>${drools-version}</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<version>${drools-version}</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-decisiontables</artifactId>
<version>${drools-version}</version>
</dependency>

<!-- Fitnesse -->
<dependency>
<groupId>org.fitnesse</groupId>
<artifactId>fitnesse</artifactId>
<version>${fitnesse-version}</version>
</dependency>

<!-- JUnit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit-version}</version>
</dependency>

<!-- Logging -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j-version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>

 

Configure your Eclipse Installed JREs to point at the JDK

In Eclipse open Preferences -> Java -> Installed JREs

Add your JDK (if necessary) and then select it

Run Maven Update to update your JRE Version

Right click in Package Explorer -> Maven -> Update Project

 

Build and Launch Fitnesse from within Eclipse

Now we have created our project let’s build and run it.

Right click on the project and select Run As -> Maven Install

You should see build success in the Console.

Now let’s launch Fitnesse.

Right click on the project and select Run As -> Run Configurations…

From the popup window click the New launch configuration icon (top left)

Change the name to Fitnesse

Change the main class to fitnesseMain.FitNesseMain

eisRunConfig001

click on the arguments tab and in program arguments add -p 8080

eisRunConfig002

click Apply

click Run

Fitnesse will start on port 8080

Now open your browser to http://localhost:8080 and you should see the fitnesse main screen

eisFitnesseMain001

Download the Source

The project code can be downloaded from github here

 

Advertisement

One comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s