Java GUI testing with Marathon - FBK · Testing Jabref GUI • All the GUI components you are...

12
Java GUI testing with Marathon Software Analysis and Testing Cu Nguyen Duy (cunduy at fbk dot eu) Alessandro Marchetto (marchetto at fbk dot eu) Paolo Tonella (tonella at fbk dot eu) Mariano Ceccato (ceccato at fbk dot eu) Academic Year 2011-2012 Wednesday, October 12, 11

Transcript of Java GUI testing with Marathon - FBK · Testing Jabref GUI • All the GUI components you are...

Page 1: Java GUI testing with Marathon - FBK · Testing Jabref GUI • All the GUI components you are developing should be tested • for fault detection • for increasing Coverage Score

Java GUI testing with Marathon

Software Analysis and TestingCu Nguyen Duy (cunduy at fbk dot eu)

Alessandro Marchetto (marchetto at fbk dot eu)Paolo Tonella (tonella at fbk dot eu)

Mariano Ceccato (ceccato at fbk dot eu)

Academic Year 2011-2012

Wednesday, October 12, 11

Page 2: Java GUI testing with Marathon - FBK · Testing Jabref GUI • All the GUI components you are developing should be tested • for fault detection • for increasing Coverage Score

Marathon

• Capture and playback tool for testing Java/Swing graphical user interfaces. (www.marathontesting.com)

• Uses the “Jython” (Python for Java) and JRuby scripting languages to store test cases.

• Test cases can be captured interactively, or written as Jython, JRuby scripts.

• Allows to insert assertions in the script easily, using a specific GUI

• Shows testing results using JUnit’s control bar

User Guide: http://www.marathontesting.com/Marathon_-_Java_GUI_Testing_files/Marathon%20User%20Guide.pdf

Wednesday, October 12, 11

Page 3: Java GUI testing with Marathon - FBK · Testing Jabref GUI • All the GUI components you are developing should be tested • for fault detection • for increasing Coverage Score

Getting start with Marathon

  A calculator application was developed (Swing)

  We want to write tests for the calculator   Ex. add two values

  Steps: 1.  create a new Marathon

project 2.  create a new empty test

(a test is a Python script file)

3.  build and run the test (recording/replay)

4. generate reports

url: http://selab.fbk.eu/swat/projects/swing-calculator.tgz

Wednesday, October 12, 11

Page 4: Java GUI testing with Marathon - FBK · Testing Jabref GUI • All the GUI components you are developing should be tested • for fault detection • for increasing Coverage Score

1. Create a new Marathon project

• Launch Marathon

• Click on the New... button to create a new project

• Name the project (e.g. Swing-Calculator-Test)

• Specify Directory (e.g same workspace)

• Set Main Class to the main class of the project (Calculator)

• Set the Class path

• bin (output) folder of eclipse project

• jar libs (if any)

Wednesday, October 12, 11

Page 5: Java GUI testing with Marathon - FBK · Testing Jabref GUI • All the GUI components you are developing should be tested • for fault detection • for increasing Coverage Score

2. Recording a test

• File > New > Exploratory Test

• Wait for the application to be launched

• Interact with the App to record events

• Insert assertions (Ctl-RightClick or Cmd-RightClick) on controls

Wednesday, October 12, 11

Page 6: Java GUI testing with Marathon - FBK · Testing Jabref GUI • All the GUI components you are developing should be tested • for fault detection • for increasing Coverage Score

3. Test execution

• Modify, improve recorded test cases if necessary

• You can record more for a test case with recording, recorded code will be inserted at the current position of the cursor

• Click on Play to run a test case

Wednesday, October 12, 11

Page 7: Java GUI testing with Marathon - FBK · Testing Jabref GUI • All the GUI components you are developing should be tested • for fault detection • for increasing Coverage Score

4. Generate report

• Select Marathon > Generate Reports

• Reports are stored in TestReports

• Open them with a browser or select Marathon > Show Reports

Wednesday, October 12, 11

Page 8: Java GUI testing with Marathon - FBK · Testing Jabref GUI • All the GUI components you are developing should be tested • for fault detection • for increasing Coverage Score

Exercises1. Record the following test: 123+456

2. Insert assertion to check if the result is 579.0

3. Adding more tests

a. 123*56

b. 213234-1234

c. 1/0

4. Modify the test (a) to 123*$1

Wednesday, October 12, 11

Page 9: Java GUI testing with Marathon - FBK · Testing Jabref GUI • All the GUI components you are developing should be tested • for fault detection • for increasing Coverage Score

Testing Jabref GUI with Marathon

Wednesday, October 12, 11

Page 10: Java GUI testing with Marathon - FBK · Testing Jabref GUI • All the GUI components you are developing should be tested • for fault detection • for increasing Coverage Score

Project settings(recommended)

Name the project jabref-gui-test

Directory a subfolder of Eclipse Jabref project

Main Class net.sf.jabref.JabRefMain

Class path - bin folder of Eclipse jabref project- jar: build/lib/Jabref-2.7.jar (*)

(*) if the file does not exist, do one of the followings:- install Apache Ant and run ant (with out any argument) within the jabref project to generate that file- open Ant View of Eclipse, drag-drop the file build.xml into the view, double click on the jars task- replace that jar file with all the jars required by jabref (take a look at the classpath specification in the build.xml file)

Wednesday, October 12, 11

Page 11: Java GUI testing with Marathon - FBK · Testing Jabref GUI • All the GUI components you are developing should be tested • for fault detection • for increasing Coverage Score

Testing Jabref GUI• All the GUI components you are developing should

be tested

• for fault detection

• for increasing Coverage Score

• Jabref GUI testing with coverage:

1. instrument jabref built code with Coverage Tool

2. run Marathon test cases as normal

Wednesday, October 12, 11

Page 12: Java GUI testing with Marathon - FBK · Testing Jabref GUI • All the GUI components you are developing should be tested • for fault detection • for increasing Coverage Score

Exercise

• Setup a Marathon project for Jabref

• Record the following events: Open a BibTeX Database > Select an item > Delete that item > Close the Databae

• Modify the recorded code, substitute the previously selected file with another

• Run the test and check the report

Wednesday, October 12, 11