Manage test data and execute automated test scenarios with FitNesse and Ranorex
Writing test scripts is more time consuming than maintaining already existing test scripts. One way to minimize the time needed to implement test scripts is to keep test data separated from test code. The less test data the test code contains, the more reusable it is. Another advantage of separating test data from test code is that testers – in most cases non-programmers – are able to generate and execute tests or test suits without thorough the deeper knowledge of test script implementation.
The following example describes how FitNesse and Ranorex can be combined to automate GUI testing without having static test scripts. Moreover, it gives a quick overview as to how to manage, maintain and execute test scripts using FitNesse.

First, download and install FitNesse from http://fitnesse.org/FrontPage.FitNesseDevelopment.DownLoad. More information about installing and getting started with FitNesse is provided by the following document written by Gojko Adzic: http://gojko.net/FitNesse/book/. He describes how one implements and executes .NET test cases using FitNesse and demonstrates how one can create human-readable test cases.
Creating Automation Base Library
UPDATED: This example is based on Ranorex 2.2.
To automate and test the VIP application with FitNesse it is necessary to implement a .NET fixture class which does all the GUI automation work.
using System;
using System.Collections.Generic;
using System.Text;
using Ranorex;
namespace NetFit
{
public class AddVIPTest : fit.ColumnFixture
{
///
/// UI Repository instance for VIP Application
///
private VIPRepo repo = VIPRepo.Instance;
private string gender;
private string lastName;
private string firstName;
///
/// Property for FirstName parameter.
/// By setting the property Ranorex directly clicks
/// the text box and simulates the keyboard events
/// Returns the current text value of the text box.
///
public string FirstName
{
set
{
this.firstName = value;
repo.VIPApplication.FirstName.Click();
Ranorex.Keyboard.Press(firstName);
}
get
{
return repo.VIPApplication.FirstName.TextValue;
}
}
///
/// Property for FirstName parameter.
/// By setting the property Ranorex directly clicks
/// the text box and simulates the keyboard events
/// Returns the current text value of the text box.
///
public string LastName
{
set
{
this.lastName = value;
repo.VIPApplication.LastName.Click();
Ranorex.Keyboard.Press(lastName);
}
get
{
return repo.VIPApplication.LastName.TextValue;
}
}
///
/// Property for Gender parameter.
/// Depending on the given value Ranorex selects
/// the right radio button.
/// Returns the currently selected gender
///
public string Gender
{
set
{
gender = value;
if (gender.Equals("Female"))
repo.VIPApplication.Gender.Female.Click();
else if (gender.Equals("Male"))
repo.VIPApplication.Gender.Male.Click();
}
get
{
if (repo.VIPApplication.Gender.Female.Checked)
return "Female";
else
return "Male";
}
}
/// Method is used to simulate a click on
/// specified button.
///
///
/// Specifies the label of the button to press
///
public void Action(string button)
{
repo.VIPApplication.Self.FindChild(button).Click();
}
///
///
/// Returns the current text value of
/// the status bar.
///
public string ValidateStatusBox()
{
return repo.VIPApplication.StatusBar.TextValue;
}
}
The “AddVIPTest” class is derived from a simple FitNesse fit.ColumnFixture class. All public declared fields within this class are accessible through a FitNesse test case as follows:
!|NetFit.AddVIPTest|
|FirstName|LastName|Gender|Action|ValidateStatusBox?|
|Marylin|Monroe|Female|Add|VIP count: 1|
|Bill|Gates|Male|Add|VIP count: 2|
|Hillary|Clinton|Female|Add|VIP count: 3|
All test data is specified in columns and rows, and “FirstName”, “LastName”, “Gender”, and “Action” are declared as test input data. Read test output data by adding the question mark ‘?’ to the “ValidateStatusBox” column. The last column in our example is used to call our “ValidateStatusBox” method and to compare the returned value with an expected value.
FitNesse uses so called “Test Pages” to execute test tables as described above. The next steps describe how to create “Test Pages” with FitNesse using its web application server.
After downloading and installing FitNesse, just start “run.bat”. Start your preferred browser and enter http://localhost/AddVipTest in the address field to create a new FitNesse test called AddVIPTest.
Specifying test
Edit the page and define the command patterns, the test runner and the Ranorex based .NET library as follows:
!!define COMMAND_PATTERN {%m -r fitnesse.fitserver.FitServer,C:\Ranorex\Fitnesse\dotnet2\fit.dll, -c C:\Ranorex\Fitnesse\dotnet2\myConfig.xml %p}
!define TEST_RUNNER {C:\Ranorex\Fitnesse\dotnet2\Runner.exe}
!path C:\Ranorex\Fitnesse\HelloWorld\HelloWorld\bin\Debug\NetFit.dll
!|NetFit.AddVIPTest|
|FirstName|LastName|Gender|Action|ValidateStatusBox?|
|Marylin|Monroe|Female|Add|VIP count: 1|
|Bill|Gates|Male|Add|VIP count: 2|
|Hillary|Clinton|Female|Add|VIP count: 3|
Save the “AddVipTest” page. To enable a “Test” button, set up the page properties within the properties menu.
Now you can start your FitNesse-managed Ranorex automated test script.

Each test case should be passed successfully. Try to force an error by changing one of the expected values. Restart the test and see what happens.
Subscribe
January 22nd, 2008 at 4:31 pm
Thanks for this informative post. I am currently taking a similar approach with my Ranorex tests.
I work with the Python tests and manually am replacing values with variables (var1 … varN) and have created a framework to feed these variables in at runtime. By tracking the input to each run I am able to verify in the database that the data was entered correctly thus providing another level of validation.
Further reuse (re) organization of the scripts come from the concept of using them as “scriptlets” that are pieced together like legos to create tests. Reuseability is very high now.
I have been wanting to further integrate with FitNesse and this provides the perfect starting point.
Thanks again,
Jason
March 11th, 2008 at 10:33 am
please send me details about ranorex
February 11th, 2009 at 5:38 am
Blog has been really helpful. I would be thankful if i could get an exmaple of implemenatation of fitnesse using java with IDE as eclipse.
January 11th, 2010 at 2:49 am
Hi there,
Thanks for your post. Where can I download Ranorexcore.dll? In order to automate Windows, what other dll do I need to include? Thanks in advance.
January 11th, 2010 at 10:26 am
You can download the complete Ranorex Trial package from
http://www.ranorex.com/download.html
When you install the Ranorex package, you have everything you need in order to automate Windows and Web applications. In general, you need all the DLLs from the “bin” folder in the Ranorex installation directory.
Regards,
Alex
January 11th, 2010 at 4:25 pm
We’ll update that article, so that the example works with the newest version of Ranorex 2.2. Because the example is totally based on the old Ranorex version.
best regards,
Christoph
April 15th, 2010 at 6:38 am
is there any solution to execute test in romote machine?