1 Software Testing and Quality Assurance Lecture 28 – Testing Class Hierarchies.

Slides:



Advertisements
Similar presentations
1 Chapter 6: Extending classes and Inheritance. 2 Basics of Inheritance One of the basic objectives of Inheritance is code reuse If you want to extend.
Advertisements

1 l Inheritance Basics l Programming with Inheritance l Dynamic Binding and Polymorphism Inheritance.
Chapter 7 Testing Class Hierarchies. SWE 415 Chapter 7 2 Reading Assignment  John McGregor and David A. Sykes, A Practical Guide to Testing Object-Oriented.
Object-Oriented Application Development Using VB.NET 1 Chapter 8 Understanding Inheritance and Interfaces.
Inheritance Java permits you to use your user defined classes to create programs using inheritance.
Chapter 11: Implementing Inheritance and Association Visual Basic.NET Programming: From Problem Analysis to Program Design.
Objectives Introduction to Inheritance and Composition (Subclasses and SuperClasses) Overriding (and extending), and inheriting methods and constructors.
Inheritance Polymorphism Briana B. Morrison CSE 1302C Spring 2010.
Chapter 10: Introduction to Inheritance
Advanced Programming in Java
Sadegh Aliakbary Sharif University of Technology Fall 2010.
1 Software Testing and Quality Assurance Lecture 12 - The Testing Perspective (Chapter 2, A Practical Guide to Testing Object-Oriented Software)
Object-Oriented PHP (1)
1 Software Testing and Quality Assurance Lecture 21 – Class Testing Basics (Chapter 5, A Practical Guide to Testing Object- Oriented Software)
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
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)
CSE 115 Week 10 March , Announcements March 21 – Lab 7 Q & A in lecture March 21 – Lab 7 Q & A in lecture March 26 – Exam 7 March 26 – Exam.
Software Testing and Quality Assurance
November 13, 2006ECEN 5543 / CSCI 5548 – Testing OO University of Colorado, Boulder 1 Testing Object-Oriented Software Principles Summary ECEN 5543 / CSCI.
1 Chapter 6 Inheritance, Interfaces, and Abstract Classes.
1 Software Testing and Quality Assurance Lecture 20 – Class Testing Basics (Chapter 5, A Practical Guide to Testing Object- Oriented Software)
Object-oriented Programming Concepts
Software Testing and Quality Assurance
Chapter 7: Inheritance Abstract Data Types Object Hierarchy Inheritance of Methods Inheritance: implicit passing of information between program components.
Chapter 10 Classes Continued
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter N - 1 Chapter 13 Polymorphism is-a relationships Interfaces.
Object-Oriented Application Development Using VB.NET 1 Chapter 8 Understanding Inheritance and Interfaces.
Chapter 7 - Generalization/Specialization and Inheritance1 Chapter 7 Generalization/Specialization and Inheritance.
Subclasses and Subtypes CMPS Subclasses and Subtypes A class is a subclass if it has been built using inheritance. ▫ It says nothing about the meaning.
Inheritance using Java
Dr. Ahmad R. Hadaegh A.R. Hadaegh California State University San Marcos (CSUSM) Page 1 Virtual Functions Polymorphism Abstract base classes.
Inheritance and Class Hierarchies Ellen Walker CPSC 201 Data Structures Hiram College.
Features of Object Oriented Programming Lec.4. ABSTRACTION AND ENCAPSULATION Computer programs can be very complex, perhaps the most complicated artifact.
Chapter 18 Object Database Management Systems. McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Outline Motivation for object.
Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Object Oriented.
AP Computer Science A – Healdsburg High School 1 Interfaces, Abstract Classes and the DanceStudio - Similarities and Differences between Abstact Classes.
CS212: Object Oriented Analysis and Design Lecture 13: Relationship between Classes.
Chapter 8 - Additional Inheritance Concepts and Techniques1 Chapter 8 Additional Inheritance Concepts and Techniques.
Chapter 12 Support for Object oriented Programming.
OO as a language for acm l OO phrase l Mental model of key concepts.
Object Oriented Software Development
Lecture 12 March 16, The Scope of a Variable What if there are two variables with the same name? –A local or block-local variable can have the same.
Java Programming Dr. Randy Kaplan. Abstract Classes and Methods.
Lecture 10 Concepts of Programming Languages Arne Kutzner Hanyang University / Seoul Korea.
Object-Oriented Programming Chapter Chapter
Object-Oriented Programming. Objectives Distinguish between object-oriented and procedure-oriented design. Define the terms class and object. Distinguish.
Object Oriented Programming
Chapter 12 Object-oriented design for more than one class.
Inheritance CSI 1101 Nour El Kadri. OOP  We have seen that object-oriented programming (OOP) helps organizing and maintaining large software systems.
Topics Inheritance introduction
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Inheritance and Class Hierarchies Chapter 3. Chapter Objectives  To understand inheritance and how it facilitates code reuse  To understand how Java.
Chapter 18 Object Database Management Systems. Outline Motivation for object database management Object-oriented principles Architectures for object database.
Lecture 2: Review of Object Orientation. © Lethbridge/La ganière 2005 Chapter 2: Review of Object Orientation What is Object Orientation? Procedural.
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
Basic Concepts of OOP.  Object-Oriented Programming (OOP) is a type of programming added to php5 that makes building complex, modular and reusable web.
Object Design More Design Patterns Object Constraint Language Object Design Specifying Interfaces Review Exam 2 CEN 4010 Class 18 – 11/03.
 Description of Inheritance  Base Class Object  Subclass, Subtype, and Substitutability  Forms of Inheritance  Modifiers and Inheritance  The Benefits.
Chapter 12: Support for Object- Oriented Programming Lecture # 18.
Factory Method. Intent/Purpose Factory Method is used to deal with a problem of creating objects without specifying the EXACT class of object that we.
Inheritance Modern object-oriented (OO) programming languages provide 3 capabilities: encapsulation inheritance polymorphism which can improve the design,
Sections Inheritance and Abstract Classes
Inheritance ITI1121 Nour El Kadri.
Inheritance and Polymorphism
Section 11.1 Class Variables and Methods
Inheritance B.Ramamurthy 11/7/2018 B.Ramamurthy.
Object Oriented Analysis and Design
Extending Classes Through Inheritance
Presentation transcript:

1 Software Testing and Quality Assurance Lecture 28 – Testing Class Hierarchies

2 Lecture Objectives To know what must be tested in code that is inherited. To learn how to encapsulate the test cases for a specific class using PACT. To learn what testing is possible for abstract classes.

3 Inheritance in Object-Oriented development Good object-oriented design requires for a very disciplined use of inheritance with substitution principle. Assumption: inheritance has been used in accordance with the substitution principle. Under this assumption, the set of test cases identified for a class is valid for a subclass of that class. Additional test cases usually apply to a subclass.

4 Subclass test requirements Testing a class in an inheritance hierarchy is generally more straightforward when approached from the top down. In testing the top classes in the hierarchy, we can address the common interface and code and then specialize the test driver code for each subclass.

5 Subclass test requirements: refinement possibilities Four general ways to define a new derived class that differ from its parent class: Add a new operation in the interface of the derived class and possibly a new method to implement each new operation. Change the specification or implementation of an operation from the superclass Change in the subclass the specification for an operation declared in the parent class. Override in the subclass a method in the parent class. Add one or more instance variables to the subclass to implement more states and/or attributes. Change the class invariant in the subclass

6 Subclass test requirements: refinement possibilities (cont...) All the test cases that apply for the parent class should apply for the subclass. We need new additional test cases for the new operations.

7 Subclass test requirements: refinement possibilities (cont...)

8 Subclass test requirements: Hierarchical, incremental testing (HIT) The incremental changes between class C and its derived class D can be used to guide the identification of what needs to be tested in D. Inherited test cases: test cases for a subclass that were identified for testing its base class.

9 Subclass test requirements: Hierarchical, incremental testing (cont...) Use analysis to determine for a subclass What test cases need to be added What inherited test cases need to be run What inherited test cases do not need to be run

10 Organizing testing software Parallel architecture for class testing (PACT): We can develop a test driver for a subclass D by deriving its Tester class from the tester class of C (D’s superclass).

11 Organizing testing software (cont...) PACT reduces the effort needed to test a new subclass. If an operation is refined in a subclass, then the corresponding tester methods can be reused in the subclass and refined as necessary to reflect new preconditions, postcondition, and/or implementation. The root of the PACT hierarchy is the abstract class Tester.

12 Organizing testing software (cont...) Each subclass of Tester must provide implementations for the abstract operations and could override methods for any of the other operations. Each subclass has the following organization: Test case methods A method corresponding to each constructor to create an object under test. A method to create an object under test in some specified state.

13 Testing abstract classes Execution-based testing of a class requires that an instance of the class be constructed We can not create an instance of abstract class, so how to test an abstract class?

14 Testing abstract classes: approach 1 A concrete subclass of the abstract class is defined solely for the purpose of testing: Disadvantage: the implementation of the abstract method cannot be propagated easily to abstract subclass without using multiple (repeated) instances.

15 Testing abstract classes: approach 1 (cont...)

16 Testing abstract classes: approach 2 Test an abstract class as part of testing the first concrete descendent Advantage: no need develop extra classes for testing Disadvantage: increase the complexity in testing the concrete class.

17 Testing abstract classes: approach 2 (cont...)

18 Testing abstract classes: approach 3 Test an abstract class using guided inspection instead of execution-based testing Abstract class provides a little or no implementation for the abstract operations. Public interfaces for abstract classes stabilize quickly. Concrete operations can easily be tested by inspection But constructors and destructors are more complicated to be tested by inspection only.

19 Testing abstract classes: recommendations Do execution-based testing. PACT offers advantages for testing families of classes. Use approach 2: Straightforward Requires relatively little additional coding effort for implementing testers. Easily perform regression testing.

20 Key points Inheritance provides a mechanism for interface and code reuse. Four ways to define a new derived class that differ from its parent class. Hierarchical, incremental testing (HIT): The incremental changes between class C and its derived class D can be used to guide the identification of what needs to be tested in D. Organizing testing software: Parallel architecture for class testing (PACT). Four approaches to test abstract classes.