Fitnesse (Lab) Alessandro Marchetto Fondazione Bruno Kessler - IRST Outline 1. Fitnesse Installation 2. Fitnesse: starting with a running example 3. Exercises 1. Try to install 2. Try to run the running example 3. Try to do the exercises 2 Install and run Fitnesse 1. 2. 3. 4. 5. Load http://fitnesse.org Click on “Download Fitnesse and Plugins” Download “fitnesse.jar” Lunch “java -jar fitnesse.jar” …. Open a Browser and lunch “http://localhost:80” Please, see the documentation 3 Install Fitnesse in Eclipse (I) 1. Download the Eclipse plugin (in a local directory) http://www.bandxi.com/fitnesse/com.bandxi.fitnesse_v1.0.2.zip 2. Install the plugin in your Eclipse 1. Lunch Eclipse 2. Select “Help Software Update…” 3. Select “Available SoftwareAdd Site Archieve …” 1 2 3 4 Install Fitnesse in Eclipse (II) 4. Chooice the com.bandxi.fitnesse_v1.0.2.zip file and confirm 5. Click “Install” 1. (before lunching the installation) Check the correct package only 2. (during the installation) Read and accept the licence 6. When restarting Eclipse… the Fitnesse plugin will be installed (Check the presence of the Fitnesse icons) 4 5.1 5.2 6 5 Our running example: Sum Calculator public class MySum { public static int sum (int a, int b) { return a+b; } } public class MyFixture extends ColumnFixture { int a,b; public int sum () { return MySum.sum(a,b); } } A full demo: http://softeng.polito.it/courses/tutorial/FitnesseInEclipse.html 6 Step-by-Step (I) 1. Create a new “Java Project” in Eclipse, called “MathOperators” 2. Write the class “Add” in the package “math” with a method “sum” that takes two integer and returns the sum package math; public class Add { public static int sum (int a, int b){ return a+b; } } 7 3. In the Eclipse project create a new directory called “Fitnesse” and add the Fitnesse library to the classpath 1. select the project right botton of the mouse New Folder … 2. select the project right botton of the mouse Fitnesse Add Fitnesse libraries… 4. Select the new “Fitnesse” directory and start Fitnesse on it 1. select the directory right botton of the mouse FitNesse Lunch FitNesse runtime on this folder … Confirm initialization … … A new fitnesse wiki is starting for the current project 3 4 8 5 5. In the wiki click “Edit” to edit the table 6. Edit the table and save it 6 9 7. See the table and try to run it. To run: 1. In the wiki click “Properties” to make the page executable 2. Check “Test” and click “Save Properties” 8. In the wiki click “Test” to run the test … 7.1 7.2 8 We need the fixture! 10 9. In the Eclipse project create a new package “fitures” 10.In the “fixtures” package create the fixtures.MyFixture fixture extending the ColomnFixture … package fixtures; import math.Add; import fit.ColumnFixture; public class MyFixture1 extends ColumnFixture { public int a; public int b; public int sum(){ int result; return Add.sum(a,b); } } 11 11. Now, run again the Fitnesse test … 11 12 Exercises… (1) Install Fitnesse (2) Run the running example (3) Download the exercise specifications http://selab.fbk.eu/swat/exercises/fitneese-1.ppt (4) For each exercise: (1) Read its specification (2) Try to apply the black-box testing technique to identify test cases (3) Implement such test cases in Fitnesse (4) Run them 13