Automated GUI testing How to test an interactive application automatically?

Slides:



Advertisements
Similar presentations
Introduction to Java 2 Programming
Advertisements

Introduction to Java 2 Programming
© by Pearson Education, Inc. All Rights Reserved.
© by Pearson Education, Inc. All Rights Reserved. continued …
Unit 091 Introduction to GUI Programming Introduction to User Interfaces Introduction to GUI Programming GUI Design Issues GUI Programming Issues Java.
Graphical User Interface (GUI) Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
0 CS 160: Design Process: Implement Event-based UI Programming, Model-View-Controller, and the Web Jeffrey Nichols IBM Almaden Research Center
Object-Oriented Analysis and Design
Stanford hci group / cs376 research topics in human-computer interaction UI Software Tools Scott Klemmer 27 October 2005.
GUI Programming in Java Tim McKenna GUI Programming Concepts l conventional programming: sequence of operations is determined by the program.
Graphical User Interfaces A Quick Outlook. Interface Many methods to create and “interface” with the user 2 most common interface methods: – Console –
Programming with App Inventor Computing Institute for K-12 Teachers Summer 2012 Workshop.
Introduction to Java Swing “We are the sultans of swing” – Mark Knopfler.
GUI Programming in Java
Java Beans.
Software Construction Lecture 10 Frameworks
Microsoft Visual Basic 2008 CHAPTER 8 Using Procedures and Exception Handling.
Welcome to CIS 083 ! Events CIS 068.
Department of Mechanical Engineering, LSUSession VII MATLAB Tutorials Session VIII Graphical User Interface using MATLAB Rajeev Madazhy
IE 411/511: Visual Programming for Industrial Applications
Capture and Replay Often used for regression test development –Tool used to capture interactions with the system under test. –Inputs must be captured;
Introduction to Matlab & Data Analysis
Intro to GUIs (Graphical User Interfaces) Section 2.5Intro. to GUIs: a GUI Greeter Section 3.7Graphical/Internet Java: Einstein's Equation.
Automated GUI testing How to test an interactive application automatically?
Chapter 8: Writing Graphical User Interfaces Visual Basic.NET Programming: From Problem Analysis to Program Design.
Designing Interface Components. Components Navigation components - the user uses these components to give instructions. Input – Components that are used.
GUI development with Matlab: GUI Front Panel Components 1 GUI front panel components In this section, we will look at -GUI front panel components -Programming.
Ch6: Software Verification. 1 Decision table based testing  Applicability:  Spec. is described by a decision table.  Tables describe:  How combinations.
Software Development Software Testing. Testing Definitions There are many tests going under various names. The following is a general list to get a feel.
Object Oriented Programming Ders 11: Interfaces Mustafa Emre İlal
Exploring an Open Source Automation Framework Implementation.
Swing and MVCS CompSci 230 Software Construction.
16 October Reminder Types of Testing: Purpose  Functional testing  Usability testing  Conformance testing  Performance testing  Acceptance.
Session 27 Swing vs. AWT. AWT (Abstract Window ToolKit) It is a portable GUI library for stand-alone applications and/or applets. The Abstract Window.
GUIs in Java Swing, Events CS2110, SW Development Methods Readings: MSD, Chapter 12 Lab Exercise.
Ch 3-4: GUI Basics Java Software Solutions Foundations of Program Design Sixth Edition by Lewis & Loftus Coming up: GUI Components.
Java Web Development with NetBeans IDE -- Kai Qian Chapter 5 JavaServer Faces (JSF) Technology.
Graphics and Event-Driven Programming in Java John C. Ramirez Department of Computer Science University of Pittsburgh.
JavaScript - A Web Script Language Fred Durao
3461 Model-View Controller Advanced GUI concepts.
Creating Graphical User Interfaces (GUI’s) with MATLAB By Jeffrey A. Webb OSU Gateway Coalition Member.
1 Creating Windows GUIs with Visual Studio. 2 Creating the Project New Project Visual C++ Projects Windows Forms Application Give the Project a Name and.
CSE1030-HR GUI The Big Picture Building the View Building the Controller Separating the Concerns Going Further.
Java Applets: GUI Components, Events, Etc. Ralph Westfall June, 2010.
Java GUI building approaches Aleksandar Kartelj Faculty of Mathematics, Belgrade 11 th Workshop “Software Engineering Education and.
Model View Controller MVC Web Software Architecture.
SilkTest 2008 R2 SP1: Silk4J Introduction. ConfidentialCopyright © 2008 Borland Software Corporation. 2 What is Silk4J? Silk4J enables you to create functional.
Week 6: Basic GUI Programming Concepts in Java Example: JFrameDemo.java container : a screen window/applet window/panel that groups and arranges components.
Slide 1 ACS Foundation Software Update Version 1.80.
Interactive Frequency Filtering Program Geoff Franz.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Oct 021 Outline What is a widget? Buttons Combo boxes Text components Message boxes.
Different Types of HCI CLI Menu Driven GUI NLI
Ajmer Singh PGT(IP) JAVA IDE Programming - I. Ajmer Singh PGT(IP) GUI (Graphical User Interface) It is an interface that uses a graphic entities along.
Sadegh Aliakbary Sharif University of Technology Fall 2011.
Oct 091 Example Program DemoInputValidation1.java DemoInputValidation2.java.
Java - hello world example public class HelloWorld { public static void main (String args[]) { System.out.println("Hello World"); }
1 Lecture 8: User Interface Components with Swing.
3461 Course Summary COSC 3461A Fall Intro to UI Design  Course plan: Implementation, Evaluation, Design  Human Computer Interaction is an.
CIS 270—Application Development II Chapter 11—GUI Components: Part I.
1 Agenda  Unit 8: Programs and Data. 2 Structured data - Array There are many situations where we want to apply the same processing to a collections.
1 Visual Basic: An Object Oriented Approach 7 – The User interface.
Support for the Development of Interactive Systems
CompSci 230 S Software Construction
Chapter 8: Writing Graphical User Interfaces
Java Look-and-Feel Design Guidelines
Lecture 27 Creating Custom GUIs
Example Program DemoLowLevelEvents.java DemoHighLevelEvents.java
Gannon University Frank Xu
Introduction to Computing Using Java
Presentation transcript:

Automated GUI testing How to test an interactive application automatically?

2 Some GUI facts Software testing accounts for 50-60% of total software development costs GUIs can constitute as much as 60% of the code of an application GUI development frameworks such as Swing make GUI development easier Unfortunately, they make GUI testing much harder

3 Why is GUI testing difficult? Event-driven architecture User actions create events An automatic test suite has to simulate these events somehow Large space of possibilities The user may click on any pixel on the screen Even the simplest components have a large number of attributes and methods JButton has more than 50 attributes and 200 methods The state of the GUI is a combination of the states of all of its components

4 Challenges of GUI testing Test case generation: What combinations of user actions to try? Oracles: What is the expected GUI behaviour? Coverage: How much testing is enough? Regression testing: Can test cases from an earlier version be re-used? Representation: How to represent the GUI to handle all the above?

5 A GUI test case 1.Select text “Some” 2.Menu “Format” 3.Option “Font”

6 A GUI Test Case 4. Combobox “Size” 5. Click on Click OK

7 A GUI Test Case 7. Select “text” 8. Click U 9. Verify that the output looks like this

8 GUI vs. business model testing GUI testing The look of the text in the editor window corresponds to the operations performed The U button is selected All appropriate actions are still enabled, i.e. we can italicize the underlined text Business model testing Word’s internal model reflects the text formatting we performed

9 Two approaches to GUI testing 1. Black box Launch application Simulate mouse and keyboard events Compare final look to an existing screen dump Very brittle test cases Cannot test business model Framework independent

10 Two approaches to GUI testing 2. Glass box Launch application in the testing code Obtain references to the various components and send events to them Assert the state of components directly Test cases harder to break Business model can be tested Framework dependent

11 A first approach The Java API provides a class called java.awt.Robot It can be used to generate native system input events Different than creating Event objects and adding them to the AWT event queue These events will indeed move the mouse, click, etc.

12 RobotDemo

13 Testing with Robot User input can be simulated by the robot How to evaluate that the correct GUI behaviour has taken place? Robot includes method public BufferedImage createScreenCapture(Rectangle screenRe ct)BufferedImageRectangle Creates an image containing pixels read from the screen

14 Problems with this approach Low-level Would rather say “Select "blue" from the colour list” than Move to the colour list co-ordinates Click Press  5 times Click Brittle test cases (regression impossible)

15 A better approach Every GUI component should provide a public API which can be invoked in the same manner via a system user event or programmatically Component behaviour should be separated from event handling code For example, class JButton contains the doClick() method

16 Unfortunately… Most GUI development frameworks are not designed in this fashion In Swing, event handling is mixed with complex component behaviour in the Look and Feel code Few components offer methods such as doClick()

17 Abbot – A Better ’Bot A GUI testing framework for Swing Works seamlessly with Junit Uses some Junit 3 features Can be used to create Unit tests for GUI components Functional tests for existing GUI apps Open source

18 Goals of the Abbot framework Reliable reproduction of user input High-level semantic actions Scripted control of actions Loose component bindings

19 Abbot overview A better Robot class is provided abbot.tester.Robot includes events to click, drag, type on any component For each Swing widget a corresponding Tester class is provided E.g. JPopupMenuTester provides a method called getMenuLabels() Components can be retrieved from the component hierarchy No direct reference to any widget is necessary

20 A typical test case JButton button = (JButton)getFinder().find( new Matcher() { public boolean matches(Component c) { return c instanceof JButton && ((JButton)c).getText().equals("OK"); }}); AbstractButtonTester tester = new AbstractButtonTester(); Tester.actionClick(button); assertEquals("Wrong button tooltip", "Click to accept", button.getToolTipText());

21 Unit Testing with Abbot demo