620 likes | 742 Views
Software Testing for Non-traditional Software . Mary Lou Soffa University of Pittsburgh soffa@cs.pitt.edu Currently on sabbatical at IBM T.J. Watson Research. Shanghai, China December 4, 2003. Research Interests . Software Engineering Testing Regression testing - maintenance
E N D
Software Testing for Non-traditional Software Mary Lou Soffa University of Pittsburgh soffa@cs.pitt.edu Currently on sabbatical at IBM T.J. Watson Research Shanghai, China December 4, 2003
Research Interests • Software Engineering • Testing • Regression testing - maintenance • Debugging • Optimizing compilers • Particular code optimizations • Properties of optimizations • Specification/profitability • Connection: program analysis
Non Traditional Software • Traditional software • Input • Program executes without user interaction and is self contained • Program produces results • Non Traditional • Event driven – user interacts with code as it executes – Graphical User Interfaces • Application operates in an environment • Database, physical environment
Outline • Testing Graphical User Interfaces • Challenges – how currently done • Test case generation • Oracles – expected results • Regression testing
Testing of Graphical Unit Interfaces (GUI) 50% of code GUI Interactionsbetween the GUI and the underlying code Underlying Code
Challenges of GUI Testing • How much testing is enough? • (Test coverage) • Is the GUI executing correctly during testing? • (Test oracles) • What test results can be salvaged from the previous test runs to test a new version? • (Regression testing) • How to represent the GUI to handle all the above? • (Representation) • How to do the testing automatically without user’s involvement?
GUI Framework • New representation for GUIs – event driven software • Test case generation based on AI planning • Unique test oracles • New event-based coverage criteria • New automated regression testing algorithms • Automated test executor • A comprehensive framework that integrates all the above components
Overview of the Framework GUI Implementation: Tools (Languages/Toolkits) GUI Specifications GUI Representation GUI Implementer Executing GUI Regression Tester Test Oracle Test Case Generator Test Coverage Evaluator Test Executor
GUI Representation GUI Implementation: Tools (Languages/Toolkits) GUI Specifications GUI Implementer GUI Model Test Designer Executing GUI Regression Tester Test Oracle Test Case Generator Test Coverage Evaluator Test Executor
Creating the GUI Model • Modeling • GUI’s state in terms of objects & their properties • Events as state transducers • GUI’s hierarchical structure
Optional Objects Caption(Button, “Cancel”) Modeling the GUI’s State • A GUI at time T is modeled using: • Objects O = {o1, o2, o3, …, om} • Properties P = {p1, p2, p3, …, pl}, where pi is an ni-ary (ni>= 1) Boolean relation of the form: Property(oj, oa, ob, …,ox, value) True/False Property Name Object
Example: Modeling the GUI’s State Form1 WState(Form1, Width(Form1, Scroll(Form1, wsNormal) 1088) TRUE) Button1 Label1 Caption(Button1, Enabled(Button1, Visible(Button1, Height(Button1, Cancel) TRUE) TRUE) 65) Align(Label1, Caption(Label1, Color(Label1, Font(Label1, alNone) “Files of type:”) clBtnFace) (tfont))
GUI Events • GUI’s state is not static • Events change the GUI’s state • Events E = {e1, e2, e3, …, en}, associated with a GUI are functions from one GUI state Si to another state Sj • Notation: Sj = e1(Si)
This is the text. This is the text. This Example: An Event State: Si SelectText (“This”) Event: e State: Sj Sj = e(Si)
Operator Example Operator :: CUT Precondition: isCurrent(Menu2). Effects: FORALL Obj in Objects Selected(Obj) ADD inClipboard(Obj) DEL onScreen(Obj) DEL Selected(Obj) ADD isCurrent(Menu1) DEL isCurrent(Menu2). Menu1 Cut Menu2 Primitive Operators Now we know how to represent the events of the GUI
GUI Modeling Steps • From the GUI’s specifications (formal/informal), • Identify objects and properties • Create operators for GUI events • Using the event classification, create hierarchical and system-interaction operators
Test Case Generator GUI Implementation: Tools (Languages/Toolkits) GUI Specifications GUI Implementer GUI Model Test Designer Executing GUI Regression Tester Test Oracle Tasks Test-Case Generator Test Coverage Evaluator Test Executor Test Case
GUI Test Cases • Individual user events • Not enough ! • Sequences of user events lead to different states • Test case: sequence of user events
SelectText (“text”) SelectText (“This”) OK Font 18 Format This is the text. This is the text. Underline OK Format Font A Test Case for WordPad S0
Selecting Test Sequences • Infinitely many • Randomly choose sequences • Expert chooses sequences • Automatically generate events for COMMONLY USED TASKS Multiple Event Sequences This is the text. This is the text. Initial State Goal State
SelectText(“This”) This is the text. SetFontSize(18) SelectText(“text”) MouseClick(U) This is the text. A Plan for a GUI Task Initial State Goal State This is the text. This is the text.
Using Primitive Operators • One operator for each event Operator :: CUT Precondition: isCurrent(Menu2). Effects: FORALL Obj in Objects Selected(Obj) ADD inClipboard(Obj) DEL onScreen(Obj) DEL Selected(Obj) ADD isCurrent(Menu1) DEL isCurrent(Menu2). File Edit View Ins Menu1 Cut Menu2
File Mail Recipient Send To Create System-Interaction Operators Sys-Interaction Operator: File_SendTo_MailRecipient = <File + SendTo + MailRecipient >
Effects of Exploiting the GUI’s Structure • Reduction in planning operators • 362 operators 32 operators • Ratio 10:1 for MS Wordpad • 20:1 for MS Word • Efficiency
Initial State This is the text. Goal State This is the text.
Planner Planner FormatFont Underline OK OK FormatFont 18 Mapping Mapping Font Format Format Font SelectText (“text”) SelectText (“This”) OK Font 18 Format Underline OK Format Font Test Case Primitive Operator Hierarchical Operator Hierarchical Operator Primitive Operator INITIAL GOAL FormatFont (“text”, Underline) FormatFont (“This”, 18pt) SelectText (“text”) SelectText (“This”)
Test Oracles GUI Implementation: Tools (Languages/Toolkits) GUI Specifications GUI Implementer GUI Model Test Designer Executing GUI Oracle GUI State (run-time) Regression Tester Expected-state Generator Tasks Expected-state sequence Test-Case Generator Execution Monitor Test Coverage Evaluator Verifier Test Case Actual State Information Verdict Test Executor
?! SelectText (“This”) Font OK Format 18 This is the text. This is the text. This is the text. SelectText (“text”) Underline OK Format Font What Is Correct Behavior Check State, not only Output !!
Actual State Expected State Automated Verifier Verdict Determine Correct Behavior • To check the GUI’s state after each event • Approaches • Manual • Automated • Challenges • Generating expected state • Extracting actual state • Comparing expected & actual states
Overview of GUI Oracle Test Case Run-time information from executing GUI Expected-state Generator GUI Model Expected State Execution Monitor Actual State Verifier Oracle Verdict
e2 e3 en e1 Expected State • Obtaining Next State • Given a test case T with S0, the initial state, and • A sequence of events • The next state Sy is obtained from the current state Sx and operator Op • Delete property P from Sx if Effects(Op) contains the command “DEL P” • Add property P in Sy if Effects(Op) contains the command “ADD P”
S1 S2 S3 Sn Deriving Expected State • Obtain S1 = e1(S0) • And Si = ei(Si-1) en e2 e3 e1 S0 • Expected state is a conjunction of properties of the form • Property(Objects…, Value)
Experiments • Purpose: determine • Time to derive expected state • Time to execute monitor and verifier • Experimental design • GUI: our version of MS Wordpad (36 modal windows, 362 events) • Test cases: generated 290 test cases (6-56 events) using an AI planner • Hardware platform: 350 mhz pentium based machine, 256 MB RAM • Properties: reduced set • Level of checking: GUI relevant property set
Deriving Expected State Total CPU time (all 290 test cases and expected states) 75.84 sec.
Automated Execution GUI Relevant-properties checking Total running time < 10 minutes
Regression Testing GUI Implementation: Tools (Languages/Toolkits) GUI Specifications GUI Specifications GUI Implementer GUI Model Test Designer Executing GUI Oracle GUI State (run-time) Regression Testing Algorithms Expected-state Generator Tasks Expected-state sequence Test-Case Generator Coverage Criteria Coverage Evaluation Algorithms Execution Monitor Verifier Test Case Coverage Report Actual State Information Verdict Test Executor
A test case of length 3 Adobe Acrobat 5.0 File Document Security OK GUI Regression Testing Problem
A test case of length 3 File Document Security OK Adobe Acrobat 6.0 GUI Regression Testing Problem Event “Document Security” no longer in menu Test case cannot be executed – unusable!!!
A New Test Case File Security Document Properties Repair the old test case to obtain this new one OK
Overview of our Regression testing • Traditional regression testing • Event-flow/component model • Repairing test cases • Case studies
Traditional Regression Testing original test suite usable test cases unusable (obsolete) test cases discard select Selected usable test cases new test cases regression test suite • Regression test-all • Selective regression testing process
Regression Testing for GUIs • Test case generation is manual – capture/replay tools • Small number of test cases • Each test case is valuable • Changes result in a large number of obsolete test cases • Structural and layout changes • Frequent modifications • Driven by constant user feedback – prototyping • Need frequent testing
Our approach GUI Regression Testing original test suite usable test cases unusable test cases select repair not repairable Selected usable test cases new test cases discard repaired regression test suite
GUI regression model • Model represent all legal sequences of events and event interactions • Two levels • Component-call-graph – built using the concept of modal window • Forms GUI component • GUI event flow graph – event structure of a component • Helps to isolate changes and repairs
follows Cut Copy Paste About … Contents … Open … Save Open … Save Definition: Event ex follows ey iff ex can be performed immediately after ey. Representing a Component File Edit Help Forms event flow graph
Component-Call Graph Main FileNew FileSave FileOpen PageSetup Print ViewOptions FormatFont Properties • Definition: Component-Call-Graph • Nodes are components in the GUI • Main is distinguished component • Edges represent the invokes relation between components, i.e., (Cx, Cy) є{edges} iff Cx invokes Cy.
Event Flow Graph File Help Edit Open Save About Contents Cut Copy Paste To File, Edit and Help To File, Edit and Help • Definition: Event Flow FG • Vertices represent events • Edges show the follows relationship • Events first available (shown in red) • Events that invoke other components (dotted lines).