Object-Oriented Software Testing. C-S 5462 Object-Oriented Software Testing Research confirms that testing methods proposed for procedural approach are.

Slides:



Advertisements
Similar presentations
Semantics Static semantics Dynamic semantics attribute grammars
Advertisements

©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 12Slide 1 Software Design l Objectives To explain how a software design may be represented.
1 ECE 453 – CS 447 – SE 465 Software Testing & Quality Assurance Instructor Kostas Kontogiannis.
Systems Analysis and Design 8th Edition
Chapter 22 Object-Oriented Systems Analysis and Design and UML Systems Analysis and Design Kendall and Kendall Fifth Edition.
Solutions to Review Questions. 4.1 Define object, class and instance. The UML Glossary gives these definitions: Object: an instance of a class. Class:
Object-Oriented Analysis and Design
2-1 © Prentice Hall, 2007 Chapter 2: Introduction to Object Orientation Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph.
Software Testing and Quality Assurance: The Testing Perspective Reading Assignment: –John McGregor and David A. Sykes, A Practical Guide to Testing Object-Oriented.
1 SWE Introduction to Software Engineering Lecture 23 – Architectural Design (Chapter 13)
© 2005 Prentice Hall8-1 Stumpf and Teague Object-Oriented Systems Analysis and Design with UML.
©Ian Sommerville 2006Software Engineering, 7th edition. Chapter 14 Slide 1 Object-oriented Design.
Chapter Chapter 1 Introduction to Object-Oriented Programming and Software Development.
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 1 Introduction to Object-Oriented Programming and Software Development.
Copyright 2004 Prentice-Hall, Inc. Essentials of Systems Analysis and Design Second Edition Joseph S. Valacich Joey F. George Jeffrey A. Hoffer Appendix.
Chapter 10 Class and Method Design
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 1 Introduction to Object-Oriented Programming and Software Development.
Object Oriented Concepts. Movement toward Objects Instead of data-oriented or process-oriented Analysis, many firms are now moving to object-oriented.
Slide 1 Chapter 10 Class and Method Design. Slide 2 REVISITING THE BASIC CHARACTERISTICS OF OBJECT-ORIENTATION.
Introduction to Software Design Chapter 1. Chapter 1: Introduction to Software Design2 Chapter Objectives To become familiar with the software challenge.
BACS 287 Basics of Object-Oriented Programming 1.
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 2: Modelling.
1 Object-Oriented Testing CIS 375 Bruce R. Maxim UM-Dearborn.
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
Copyright 2002 Prentice-Hall, Inc. Modern Systems Analysis and Design Third Edition Jeffrey A. Hoffer Joey F. George Joseph S. Valacich Chapter 20 Object-Oriented.
Unified Modeling Language, Version 2.0
1. 2 Object-Oriented Concept Class & Object Object-Oriented Characteristics How does it work? Relationships Between Classes Development Tools Advantage.
11 Chapter 11 Object-Oriented Databases Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
©Ian Sommerville 2006Software Engineering, 8th edition. Chapter 8 Slide 1 Object-oriented and Structured System Models.
Inheritance - Polymorphism ITI 1121 Nour El Kadri.
Sommerville 2004,Mejia-Alvarez 2009Software Engineering, 7th edition. Chapter 8 Slide 1 System models.
Systems Analysis & Design 7 th Edition Chapter 5.
Systems Analysis and Design 8 th Edition Chapter 6 Object Modeling.
Software Testing Reference: Software Engineering, Ian Sommerville, 6 th edition, Chapter 20.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 14 Slide 1 Object-oriented Design.
UHD::3320::CH121 DESIGN PHASE Chapter 12. UHD::3320::CH122 Design Phase Two Aspects –Actions which operate on data –Data on which actions operate Two.
Fall 2010 CS4310 Requirements Engineering A Brief Review of UML & OO Dr. Guoqiang Hu Department of Computer Science UTEP 1.
Basic OOP Concepts and Terms. In this class, we will cover: Objects and examples of different object types Classes and how they relate to objects Object.
Object-Oriented Analysis and Design. Lesson 1: Introduction to Software Engineering.
BCS 2143 Object Oriented Design Using UML. Objectives Objects Interactions Finding Classes Relationship Between Classes Attribute and Operation Class.
Information System Design (IT60105) Lecture 26 Object-Oriented System Testing.
Slide 1 Systems Analysis and Design With UML 2.0 An Object-Oriented Approach, Second Edition Chapter 2: Introduction to Object-Oriented Systems Analysis.
What is Object-Oriented?  Organization of software as a collection of discreet objects that incorporate both data structure and behavior.
1 Testing Object- Oriented Programs CS 4311 J. McGregor and D. Sykes. A Practical Guide to Testing Object-Oriented Software, Addison-Wesley, I. Burnstein.
Object-Oriented Modeling: Static Models. Object-Oriented Modeling Model the system as interacting objects Model the system as interacting objects Match.
Chapter 3 Part II Describing Syntax and Semantics.
 Objects versus Class  Three main concepts of OOP ◦ Encapsulation ◦ Inheritance ◦ Polymorphism  Method ◦ Parameterized ◦ Value-Returning.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Testing OO software. State Based Testing State machine: implementation-independent specification (model) of the dynamic behaviour of the system State:
Slide 1 Systems Analysis and Design With UML 2.0 An Object-Oriented Approach, Second Edition Chapter 2: Introduction to Object-Oriented Systems Analysis.
1 Unified Modeling Language, Version 2.0 Chapter 2.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
Lecture 2: Review of Object Orientation. © Lethbridge/La ganière 2005 Chapter 2: Review of Object Orientation What is Object Orientation? Procedural.
PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 5th Edition Copyright © 2015 John Wiley & Sons, Inc. All rights.
Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall Appendix A Object-Oriented Analysis and Design A.1.
CSCI 383 Object-Oriented Programming & Design Lecture 7 Martin van Bommel.
Testing in OO Environment The reasons for testing is not any different for any of the design and implementation methodologies, including OO methodology.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
Software Testing Reference: Software Engineering, Ian Sommerville, 6 th edition, Chapter 20.
Basic Characteristics of Object-Oriented Systems
Introduction to UML and Rational Rose UML - Unified Modeling Language Rational Rose 98 - a GUI tool to systematically develop software through the following.
CSCE 240 – Intro to Software Engineering Lecture 3.
ISBN Chapter 12 Support for Object-Oriented Programming.
Slide 1 Unified Modeling Language, Version 2.0 Object-Oriented SAD.
Business System Development
The Movement To Objects
Systems Analysis and Design With UML 2
Chapter 20 Object-Oriented Analysis and Design
Basic OOP Concepts and Terms
Presentation transcript:

Object-Oriented Software Testing

C-S 5462 Object-Oriented Software Testing Research confirms that testing methods proposed for procedural approach are not adequate for OO approach OO software testing poses additional problems due to the distinguishing characteristics of OO Testing time for OO software found to be increased compared to testing procedural software

C-S 5463 Brief review of software testing Classifications based on testing stages –Unit testing –Integration testing –System testing –Acceptance testing Classifications based on test case generation methods –Black-box testing –White-box testing

C-S 5464 Brief review of software testing (continued) Use of “stubs” in software testing –If two units are supposed to interact with each other, and only one unit has been developed, then a “template” or “stub” of the other unit can be developed just to test the interactions –Advantage: the developer of the first unit need not wait until the second unit is developed –Disadvantage: testing must be repeated after the actual second unit is developed

C-S 5465 Testing methods within a class using STUBs public class WaterTankController { public static void main (String[] args) { Sensor sensorObject = new Sensor (); Alarm alarmObject = new Alarm(); int waterLevel = sensorObject.getReading (); checkReading (waterLevel); } public static void checkReading (int w) { if (w 100) System.out.println (“ Invalid reading ”); else if ((w >= 0 && w = 80 && w <= 100)){ System.out.println (“Water level exceeded the limit – EMERGENCY”); alarmObject.raiseAlarm (waterLevel); } else System.out.println (“ Normal range ”); }

C-S 5466 Testing Methods … STUBs (continued) public class Sensor { … public int getReading () {return 10;} } public class Alarm { … public void raiseAlarm (int n) { System.out.println (“ Alarm raises ”); } Stub Instructor: discuss the consequences of using stubs

C-S 5467 Issues in Object-Oriented Software Testing Unit of testing –method or class? what are the consequences? Implications of encapsulation and composition –how to test encapsulation? Implications of inheritance –superclass needs to know subclasses? Implications of Polymorphism –behavioral equivalence

C-S 5468 Unit of testing – method as unit testing methods and tools for procedural approach can be used to test individual methods in each class stubs used for interacting methods from other classes consequences: access restrictions on methods and encapsulation are not tested nevertheless, methods must be tested individually to ensure the correctness of algorithms, parameter passing, …

C-S 5469 Unit of testing – class as unit a more common view agreed by most people in OO community required: –individual methods must be tested for correctness OO metrics report: –classes that have methods whose parameters are objects are more likely to contain more errors than the methods that do not contain objects as parameters

C-S Implications of inheritance common approach –flatten a subclass by copying the code of inherited methods and attributes Instructor: explain with an example –each subclass must be tested individually –after testing, the inheritance hierarchy must be restored back consequences –any change in a superclass requires re-testing of the superclass and all its descendants

C-S Implications of polymorphism superclass needs to know all its descendants –reason: subclass objects are expected to behave as if superclass objects consequences: –any change in subclass requires re-testing of the subclass and all its superclasses because of polymorphic substitutions

C-S Example – polymorphic substitutions public class Rectangle { public Rectangle (…) { …} public boolean isEnclosed (Point p) {…} // returns true if Point p is //enclosed inside this rectangle …. } // “RoundedRectangle” inherits “Rectangle” – keyword in Java is “extends” public class RoundedRectangle extends Rectangle { public RoundedRectangle (…) {…} public boolean isEnclosed (Point p) {…} // redefined version of the //superclass method //– points at the four corners will be ignored }

C-S Client code that uses Rectangle and RoundedRectangle public class GeometricObjects { public static void main (String[] args) { Rectangle rect; RoundedRectangle round = new RoundedRectangle(…); rect = round; // polymorphic substitution Point p = new Point (…); // take the top left corner of the rectangle if (rect.isEnclosed(p)) System.out.println (“ Point is enclosed “); else System.out.println (“ Point is not enclosed “); }

C-S OO Testing – some more challenges parameterized classes (templates) –a class such as Course[T] must be tested for every substitution of T within that application static variables –those that are common for all instances of a class –must be tested for every new instance of this class to ensure that the static variable is accessible and is consistent with respect to its access languages that support assertions such as pre and post-conditions for methods (e.g., Eiffel, COLD) –body of the method must be executed to make sure that each pre and post-condition is checked

C-S UML and OO testing Use case model –describes the interactions of a typical user with the system –GUI testing scenarios covered  system testing –details of use case instances will help identify the parameters, and return values –Caution: use case instances may not provide the types of parameters and return values

C-S UML and OO testing (continued) Logical view –described by class and object diagrams –describes the static relationships between classes and objects –can be tested manually by code walkthrough and/or by executing objects –system testing

C-S UML and OO testing (continued) State model –state machines are used extensively in software testing –procedural approach uses one state machine that describes the states of the entire system –OO approach describes the state of each object separately modularity separation of concern –unit testing

C-S UML and OO testing (continued) State model (continued) –the actions included in a transition correspond to methods in the classes –testing each transition cover all methods that manipulate the object –testing the events correspond to the interactions among the objects –testing all the states of an object leads to the evaluation of the cohesion of the object Cohesion: appropriateness of the object to complete its expected role in the application

C-S UML and OO testing (continued) Interaction view –described by sequence and collaboration diagrams –testing sequence of message passing test all possible communication scenarios Includes concurrency –testing timing constraints in message passing leads to performance testing –unit testing and integration testing

C-S UML and OO testing (continued) Activity diagrams –describe the details of a use case or the details of a method –synonymous to “data flow” –testing an activity diagram is similar to the flow graph of a method or a use case white-box testing

C-S References Paul C. Jorgensen, “Software Testing – A Craftsman’s Approach” (Second Edition), CRC Press, 2002, ISBN: Robert V. Binder, “Testing Object-Oriented Systems”, Addison-Wesley, 2000, ISBN: