460 likes | 803 Views
Software Testing. Department of Computing Science University of Alberta CMPUT 402 Software Engineering. Outlines. Testing overview Testing object-oriented systems Testing object-oriented frameworks Testing object-oriented framework instantiations. Testing Overview. Introduction.
E N D
Software Testing Department of Computing Science University of Alberta CMPUT 402 Software Engineering
Outlines • Testing overview • Testing object-oriented systems • Testing object-oriented frameworks • Testing object-oriented framework instantiations.
Introduction • Software testing • Verification activity • Time consuming and costly. • No correctness proof. • Increase user confidence
Testing Phases • Specification testing • Design testing • Implementation testing (software testing) • Dynamic • Static
Test Suite … Test case Software test plan • Document to explain testing approach Test case
Elements of a Test Case • Reference number • Description • Preconditions • Input • Expected output
Test Case (TC) Example TC#:S-221 TC Description:This test is to check the response to an invalid input selection. TC Precondition:Go to screen Flight_Management TC Input:Enter <F7> TC Expected Output:Error message: “Invalid input, Enter “1” to “4” or ESC”
Implementation testing levels • Unit testing • Integration testing • System testing • Regression testing
Unit testing • Module testing • Testing approaches • Black-box • White-box
Example: problem statement Given two integers, find the larger. If larger is less than 1, return 1.
Example: Black-box testing Given two integers, find the largest. If largest is less than 1, return 1.
White-box testing • Statement coverage • Graph based • Branch coverage • Condition coverage • Path coverage
Example: Statement Coverage 1 int maxPositive(int n1, int n2) { 2 if (n1<=1 && n2<=1) 3 n1=1; 4 if (n1<=n2) 5 n1=n2; 6 return n1; } TC Inputs: n1=n2=1
1,2 3 4 5 6 TC#1 Inputs: n1=n2=1 TC#2 Inputs: n1=2, n2=0 Example: Branch Coverage 1 int maxPositive(int n1, int n2) { 2 if (n1<=1 && n2<=1) 3 n1=1; 4 if (n1<=n2) 5 n1=n2; 6 return n1; }
TC#3 Inputs: n1=0, n2=2 Example: Condition Coverage 1 int maxPositive(int n1, int n2) { 2 if (n1<=1 && n2<=1) 3 n1=1; 4 if (n1<=n2) 5 n1=n2; 6 return n1; } 1,2 3 4 5 TC#1 Inputs: n1=n2=1 6 TC#2 Inputs: n1=2, n2=0
TC#4 Inputs: n1=n2=0 Example: Path Coverage 1 int maxPositive(int n1, int n2) { 2 if (n1<=1 && n2<=1) 3 n1=1; 4 if (n1<=n2) 5 n1=n2; 6 return n1; } 1,2 3 4 5 TC#1 Inputs: n1=n2=1 6 TC#2 Inputs: n1=2, n2=0 TC#3 Inputs: n1=0, n2=2
Integration Testing • Non-incremental (big-bang) • Incremental • Top-down (stubs needed) • Bottom-up (drivers needed) • Sandwich
System Testing • Performed in terms of Inputs and outputs of the system. • Performed on the targeted platform. • Goals: • Reveal bugs that are represented only at system level. • Demonstrate that the system implements all required capabilities. • Answer the question: Can we ship it yet?
Regression Testing • Ensuring that modifications have not caused unintended effects. • Retesting is required
Object-oriented testing • No sequential procedural executions. • No functional decomposition. • Unique problems • Encapsulation • Inheritance • Polymorphism • Why it is different?
Object-oriented testing levels • Method testing. • Class testing. • Cluster testing. • System testing. • Regression testing
Class testing • Tests classes by sending messages to methods one at a time. • Requires drivers and stubs. • May have to test more than one method at a time to test the collaboration of methods. • Inherited method have to be tested.
Alpha-Omega Cycle Class Testing • Alpha state: object declaration state. • Omega state: object destruction state. • Alpha-omega cycle testing: takes objects from alpha to omega states by sending messages to every method at least once. • Method ordering (constructor, accessor, predicate, modifier, destructor)
Example Class person { person(String n, int a) { name=n; age=a; } constructor void setName(String n) { name=n; } modifier void setAge(int a) { age=a; } modifier String getName() { return name; } accessor int getAge() { return age; } accessor int isOld() { if age>50 return 1; return 0;} predicate String name; int age; }
Example (Cont’d) Class driver { … void test() { person Tom= new Tom(“Tom”, 20); String name=Tom.getName(); int a=Tom.getAge(); if (Tom.isOld()) { … } setName(“old Tom!!”); setAge(60); … } … }
Cluster testing • Cluster: collection of classes cooperating with each other via messages. • Goal: test the interaction among the objects of the classes that forms the cluster. • Techniques: • Message Quiescence • Event Quiescence
Message Quiescence • Method/Method path (MM-Path): sequence of method executions linked by messages. • Starts with a method and ends with another method that does not issue a message.
MM-Paths 1 2 3 MM-Path Message Event Class 3 Class 1 meth2 meth1 meth1 meth2 meth3 Class 2 meth1 meth3 meth2
Event Quiescence • Atomic System Function (ASF): MM-Path Input Event Output Event
INPUT PORT EVENT A A B B OUTPUT PORT EVENT Class 3 Class 1 meth2 meth1 1 meth1 meth2 meth3 INPUT PORT EVENT OUTPUT PORT EVENT Class 2 2 meth1 meth3 3 MM-Path meth2 Message Event
Example • ATM pin entry • Customer enters card (event). • Card is validated. • Screen requesting pin entry is displayed. • Digits are touched and displayed. • Pin is checked.
ASF Starts here CardSlot Screen memberCard showMessage ValidateCard Security NumKeypad checkPin getKeyEvents parseKeyEvent ASF ends here Customer inserts card Message is displayed Key pushers
Definitions • OO-Framework • Reusable design and implementation of a system or subsystem [Beck+ 94] • Design + code + hooks • Hooks • Places at which users can add their own components.
Importance • Why do we have to care about testing frameworks? • Framework defects passes on to all instantiations. • Hard to discover framework defects at the instantiation development stages. • Little research has been carried out.
Framework testing • Components (classes and small clusters) • black-box • class associations • Hooks • Compatibility and completeness • Problem Solving
Testing OO-framework Problems • Testing framework implementation • Developing testable model for the framework specifications. • Developing a test suite generator technique. • Testing framework hooks • …
Testing OO-framework Problems (Cont’d) • Testing framework hooks • Formalizing hook requirements. • Developing testable model for hook methods. • Integrating hook method model with framework specification model. • Extending framework implementation test suite generator technique. • Developing an approach to test hook compatibility and completeness
Framework instantiation parts • Framework used components. • Interface components. • Other instantiation components
Importance • Why do we have to deal with framework instantiations in a special way? • Part of the code is tested. • Part of the code is not needed. • Part of the code is extended.
Testing framework instantiation problems • Testing the used portion of the framework code. • Testing the extensibility of the framework. • Testing the framework interfaces. • Testing other instantiation components. • Integration testing
Summary • Testing importance • OO-technology effects testing. • OO-Framework technology effect testing.
References • G. Myers, The art of software testing, Wiley-Interscience, 1979. • B. Beizer, Software Testing Techniques, Van Nostrand reinhold, 2nd edition, 1990. • R. Binder, Testing object-oriented systems, Addison Wesley, 1999. • M. Hanna, Testing object-oriented systems for QA professionals, PSQT/PSTT 2000 North Minneapolis, MN, conference tutorial H4, 2000. • M. Petchiny, Object-oriented testing, http://www.cs.queensu.ca/home/shepard/599.dir/petchiny/OOPRESENTATION.ppt