Overview
In this post we will migrate our tests to Fitnesse using the Wili Pages
Problem Domain
So far we have created a simple rule and a JUnit test to test it. But what if the client wants to see what we have? They’re not going to want to read JUnit tests written in Java. They want the tests and data to be presented in a format that they can understand.
Furthermore, what if the client wants to change the test data? Our test so far has two Person objects, one aged 18 and one aged 21. What if the client wants to add more Person objects? They’re not going to want to go editing Java code – even if it is a JUnit test; and they’re certainly not going to want to fire up Eclipse. They want a simple, user friendly interface.
Enter Fitnesse…
Approach
First let’s create the Wiki page that defines our test. This will give us a good idea of the Fixtures we need to put in place to bolt everything together. Once we have done this, we will go on to create the Fixtures and run complete Application tests.
Creating the Web Page
Startup Fitnesse by running the Run Configuration we used in Part 1.
This will launch Fitnesse on port 8080.
Open your browser to http://localhost:8080/
This will display the following page:
click the edit button and change the content to the following:
!1 Skills421 Drools Fitnesse Example | Test Suites | | [[Person Tests][FitNesse.PersonTests]] | Simple Rules Tests using Person Facts |
click save and your page will look like the following
click on the red [?] on the page and this will create a new default page and open it in edit mode.
click save
click Add -> Test Page
Page Name: SimplePersonTest
click save
Your PersonTests page will now look like this
Click on the Simple Person Test link
click edit
replace the text with the following:
!contents -R2 -g -p -f -h !2 Test Data Setup !3 Person !| com.skills421.fixtures.PersonFixture | |firstname|lastname|age|cmHeight|kgWeight| |Jon | Doe |18 |1.8 |80 | |Jane | Doe |22 |1.9 |70 |
Click save and your page will look like this
click on Test and you will see the following error:
Create the PersonFixture