Introduction to Software Testing Chapter 7.1 Engineering Criteria for Technologies Paul Ammann & Jeff Offutt www.introsoftwaretesting.com.

Slides:



Advertisements
Similar presentations
Object-Oriented Programming Python. OO Paradigm - Review Three Characteristics of OO Languages –Inheritance It isn’t necessary to build every class from.
Advertisements

Graph Coverage for Design Elements 1.  Use of data abstraction and object oriented software has increased importance on modularity and reuse.  Therefore.
Introduction to Software Testing Chapter 9.2 Challenges in Testing Software – Software Testability Paul Ammann & Jeff Offutt
Chapter 8 Inheritance Part 2. © 2004 Pearson Addison-Wesley. All rights reserved8-2 Outline Creating Subclasses Overriding Methods Class Hierarchies Inheritance.
Intro to OOP with Java, C. Thomas Wu Inheritance and Polymorphism
1 Software Testing and Quality Assurance Lecture 12 - The Testing Perspective (Chapter 2, 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.
Inheritance. In this chapter, we will cover: The concept of inheritance Extending classes Overriding superclass methods Working with superclasses that.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Aalborg Media Lab 23-Jun-15 Inheritance Lecture 10 Chapter 8.
(C) Copyright All Rights Reserved.1 Example.
Data Abstraction and Object- Oriented Programming CS351 – Programming Paradigms.
Testing OO Programs (7.1, 2.2.2, 2.4.2) Course Software Testing & Verification 2014/15 Wishnu Prasetya.
Inheritance. © 2004 Pearson Addison-Wesley. All rights reserved 8-2 Inheritance Inheritance is a fundamental object-oriented design technique used to.
Programming Languages and Paradigms Object-Oriented Programming.
Chapter 15 – Inheritance, Virtual Functions, and Polymorphism
An Object-Oriented Approach to Programming Logic and Design
Introduction to Software Testing Chapter 2.4 Graph Coverage for Design Elements Paul Ammann & Jeff Offutt
Introduction to Software Testing Chapter 7.1 Engineering Criteria for Technologies Paul Ammann & Jeff Offutt
Software Testing and Maintenance Lecture 4 Graph Coverage for Design Element Paul Ammann & Jeff Offutt Instructor: Hossein Momeni Mazandaran.
Features of Object Oriented Programming Lec.4. ABSTRACTION AND ENCAPSULATION Computer programs can be very complex, perhaps the most complicated artifact.
Method Overriding Remember inheritance: when a child class inherits methods, variables, etc from a parent class. Example: public class Dictionary extends.
CS200 Algorithms and Data StructuresColorado State University Part 4. Advanced Java Topics Instructor: Sangmi Pallickara
Introduction to Software Testing Chapter 8.1 Building Testing Tools –Instrumentation Paul Ammann & Jeff Offutt
Inheritance in the Java programming language J. W. Rider.
Inheritance - Polymorphism ITI 1121 Nour El Kadri.
Introduction to Software Testing Chapter 9.3 Integration and Object- Oriented Testing Paul Ammann & Jeff Offutt
1 COMP313A Programming Languages Object Oriented Progamming Languages (3)
Introduction to Software Testing Chapter 5.3 Integration and Object-Oriented Testing Paul Ammann & Jeff Offutt
1 Graph Coverage (4). Reading Assignment P. Ammann and J. Offutt “Introduction to Software Testing” ◦ Section
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2008 Pearson Education, Inc., Upper.
Chapter 12 Support for Object oriented Programming.
Software Verification Graph Model 2. 2 Graph Coverage Four Structures for Modeling Software Graphs Logic Input Space Syntax Use cases Specs Design Source.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
Introduction to Software Testing (2nd edition) Chapter 7.4 Graph Coverage for Design Elements Paul Ammann & Jeff Offutt
Lecture 10 Concepts of Programming Languages Arne Kutzner Hanyang University / Seoul Korea.
Introduction to Software Testing Chapter 5.3 Integration and Object-Oriented Testing Paul Ammann & Jeff Offutt
Introduction to Software Testing Chapter 5.3 Integration and Object-Oriented Testing Paul Ammann & Jeff Offutt
Object-Oriented Programming Chapter Chapter
Testing Inheritance & Polymorphism in OO Software using Formal Specification Presented by : Mahreen Aziz Ahmad (Center for Software Dependability, MAJU)
Testing OO software. State Based Testing State machine: implementation-independent specification (model) of the dynamic behaviour of the system State:
ISBN Object-Oriented Programming Chapter Chapter
Graph Coverage for Design Elements 1.  Use of data abstraction and object oriented software has increased importance on modularity and reuse.  Therefore.
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.
Java Software Solutions Lewis and Loftus Chapter 8 Copyright 1997 by John Lewis and William Loftus. All rights reserved. 1 Inheritance -- Introduction.
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
Recap Introduction to Inheritance Inheritance in C++ IS-A Relationship Polymorphism in Inheritance Classes in Inheritance Visibility Rules Constructor.
Coupling-based Criteria for Integration Testing Journal of Software Testing, Verification, and Analysis, 8(3): , September 1998, Jenny Jin and Jeff.
Software Testing and Maintenance Lecture 3 Graph Coverage for Source Code Paul Ammann & Jeff Offutt Instructor: Hossein Momeni Mazandaran.
 Description of Inheritance  Base Class Object  Subclass, Subtype, and Substitutability  Forms of Inheritance  Modifiers and Inheritance  The Benefits.
Chapter 2 : Graph Coverage (part 2)
ISBN Chapter 12 Support for Object-Oriented Programming.
Design issues for Object-Oriented Languages
Modern Programming Tools And Techniques-I
Paul Ammann & Jeff Offutt
Testing Object-Oriented Software Test Coverage Criteria
Inheritance and Polymorphism
Paul Ammann & Jeff Offutt
Software Verification
Testing Object-Oriented Software Concepts and Definitions
Graph Coverage for Design Elements CS 4501 / 6501 Software Testing
Paul Ammann & Jeff Offutt
Paul Ammann & Jeff Offutt
Graph Coverage for Design Elements CS 4501 / 6501 Software Testing
Java Programming, Second Edition
Inheritance.
Lecture 10 Concepts of Programming Languages
Paul Ammann & Jeff Offutt
Presentation transcript:

Introduction to Software Testing Chapter 7.1 Engineering Criteria for Technologies Paul Ammann & Jeff Offutt

Introduction to Software Testing (Ch 7), © Ammann and Offutt 2 The Technologies n Chapters 1-5 emphasize criteria on four models of software n Emphasis in each chapter was first on the criteria, then on how to construct the models from different software artifacts n This chapter discusses how to apply the criteria to specific technologies –Most of the ideas in this chapter were developed after the year 2000 –Thus they are still evolving

Introduction to Software Testing (Ch 7), © Ammann and Offutt 3 Chapter 7 Outline 1. Object-Oriented Software 2. Web Applications and Web Services 3. Graphical User Interfaces 4. Real-Time and Embedded Software Object-Oriented Software

Introduction to Software Testing (Ch 7), © Ammann and Offutt 4 Section 7.1 Outline 1.Overview 2.Types of Object-Oriented Faults 1.Example 2.The Yo-Yo Graph and Polymorphism 3.Categories of Inheritance Faults 4.Testing Inheritance, Polymorphism and Dynamic Binding 5.Object-Oriented Testing Criteria Overview

Introduction to Software Testing (Ch 7), © Ammann and Offutt 5 Inheritance n Enhance derived features (overriding) n Restrict derived features n Add new features (extension) A derived class has everything its parent has, plus it can: Allows common features of many classes to be defined in one class

Introduction to Software Testing (Ch 7), © Ammann and Offutt 6 Inheritance (2) Declared type:The type given when an object reference is declared Clock w1; // declared type Clock Actual type:The type of the current object w1 = new Watch(); // actual type Watch In Java, the method that is executed is the lowest version of the method defined between the actual and root types in the inheritance hierarchy A C B

Introduction to Software Testing (Ch 7), © Ammann and Offutt 7 Polymorphism n The same variable can have different types depending on the program execution n If B inherits from A, then an object of type B can be used when an object of type A is expected n If both A and B define the same method M (B overrides A), then the same statement might call either A’s version of M or B’s version

Introduction to Software Testing (Ch 7), © Ammann and Offutt 8 Subtype and Subclass Inheritance n Subtype Inheritance : If B inherits from A, any object of type B can be substituted for an object of type A –A laptop “is a” special type of computer –Called substitutability n Subclass Inheritance : Objects of type B may not be substituted for objects of type A –Objects of B may not be “type compatible”

Introduction to Software Testing (Ch 7), © Ammann and Offutt 9 Testing OO Software 1.Intra-method testing : Testing individual methods within classes 2.Inter-method testing : Multiple methods within a class are tested in concert 3.Intra-class testing : Testing a single class, usually using sequences of calls to methods within the class 4.Inter-class testing : More than one class is tested at the same time (integration)

Introduction to Software Testing (Ch 7), © Ammann and Offutt 10 Section 7.1 Outline 1.Overview 2.Types of Object-Oriented Faults 1.Example 2.The Yo-Yo Graph and Polymorphism 3.Categories of Inheritance Faults 4.Testing Inheritance, Polymorphism and Dynamic Binding 5.Object-Oriented Testing Criteria Example

Introduction to Software Testing (Ch 7), © Ammann and Offutt 11 Example DU Pairs and Anomalies B +h () +i () -x A -u -v -w +h() +i() +j() +l() C +i () +j () +l () -y MethodDefs Uses A::h (){A::u, A::w} A::i (){A::u} A::j (){A::v}{A::w} A::l(){A::v} B::h(){B::x} B::i(){B::x} C::i() C::j(){C::y} C::l(){A::v} Consider what happens when an overriding method has a different def-set than the overridden method def-use DU anomaly DU anomaly A::h() calls j(), B::h() does not

Introduction to Software Testing (Ch 7), © Ammann and Offutt 12 Section 7.1 Outline 1.Overview 2.Types of Object-Oriented Faults 1.Example 2.The Yo-Yo Graph and Polymorphism 3.Categories of Inheritance Faults 4.Testing Inheritance, Polymorphism and Dynamic Binding 5.Object-Oriented Testing Criteria The Yo-Yo Graph and Polymorphism

Introduction to Software Testing (Ch 7), © Ammann and Offutt 13 Polymorphism Headaches (Yo-Yo) A +d () +g () +h () +i () +j () +l () Instantiated type B k() h()i() C j()i()l() A d()j()g()h()i()l() Object is of type A A::d ()

Introduction to Software Testing (Ch 7), © Ammann and Offutt 14 Polymorphism Headaches (Yo-Yo) A +d () +g () +h () +i () +j () +l () B +h () +i () +k () B h()i()k() Instantiated type B k() h()i() C j()i()l() A d()j()g()h()i()l() C j()i()l() A d()j()g()h()i()l() Object is of type B B::d ()

Introduction to Software Testing (Ch 7), © Ammann and Offutt 15 Polymorphism Headaches (Yo-Yo) A +d () +g () +h () +i () +j () +l () B +h () +i () +k () C +i () +j () +l () C j()i()l() B h()i()k() Instantiated type B k() h()i() C j()i()l() A d()j()g()h()i()l() C j()i()l() A d()j()g()h()i()l() B h()i() k() A d()j()g()h()i()l() Object is of type C, C::d ()

Introduction to Software Testing (Ch 7), © Ammann and Offutt 16 Section 7.1 Outline 1.Overview 2.Types of Object-Oriented Faults 1.Example 2.The Yo-Yo Graph and Polymorphism 3.Categories of Inheritance Faults 4.Testing Inheritance, Polymorphism and Dynamic Binding 5.Object-Oriented Testing Criteria Categories of Inheritance Faults

Introduction to Software Testing (Ch 7), © Ammann and Offutt 17 Potential for Faults in OO Programs Complexity is relocated to the connections among components Less static determinism – many faults can now only be detected at runtime Inheritance and Polymorphism yield vertical and dynamic integration Aggregation and use relationships are more complex Designers do not carefully consider visibility of data and methods

Introduction to Software Testing (Ch 7), © Ammann and Offutt 18 Object-oriented Faults n Only consider faults that arise as a direct result of OO language features: –inheritance –polymorphism –constructors –visibility n Language independent (as much as possible)

19 Introduction to Software Testing (Ch 7), © Ammann and Offutt OO Faults and Anomalies AcronymFault / Anomaly ITUInconsistent Type Use SDAState Definition Anomaly SDIHState Definition Inconsistency SDIState Defined Incorrectly IISDIndirect Inconsistent State Definition ACB1Anomalous Construction Behavior (1) ACB2Anomalous Construction Behavior (2) ICIncomplete Construction SVAState Visibility Anomaly Examples shown

Introduction to Software Testing (Ch 7), © Ammann and Offutt 20 Inconsistent Type Use (ITU) n No overriding (no polymorphism) n C extends T, and C adds new methods (extension) n An object is used “as a C”, then as a T, then as a C n Methods in T can put object in state that is inconsistent for C Vector -array +insertElementAt() +removeElementAt() Stack +pop (): Object +push (): Object call // Stack is empty! s.push (“Steffi”); s.push (“Joyce”); s.push (“Andrew”); dumb (s); s.pop(); void dumb (Vector v) { v.removeElementAt (v.size()-1); }

Introduction to Software Testing (Ch 7), © Ammann and Offutt 21 State Definition Anomaly (SDA) n X extends W, and X overrides some methods n The overriding methods in X fail to define some variables that the overridden methods in W defined W v u m() n() X x n() Y w m() W::m () defines v and W::n() uses v X::n () uses v Y::m () does not define v For an object of type Y, a data flow anomaly exists and results in a fault if m() is called, then n()

Introduction to Software Testing (Ch 7), © Ammann and Offutt 22 State Definition Inconsistency (SDIH) n Hiding a variable, possibly accidentally n If the descendant’s version of the variable is defined, the ancestor’s version may not be W v u m() n() X x n() Y v m() Y overrides W’s version of v Y::m() defines Y::v X::n() uses v For an object of type Y, a data flow inconsistency may exist and result in a fault if m() is called, then n()

Introduction to Software Testing (Ch 7), © Ammann and Offutt 23 Anomalous Construction Behavior (ACB1) n Constructor of W calls a method f() n A child of W, X, overrides f() n X::f() uses variables that should be defined by X’s constructor W W() f() X x f() Calls Uses Overrides When an object of type X is constructed, W() is run before X(). When W() calls X::f(), x is used, but has not yet been given a value!

Introduction to Software Testing (Ch 7), © Ammann and Offutt 24 State Visibility Anomaly (SVA) n A private variable v is declared in ancestor W, and v is defined by W::m() n X extends W and Y extends X n Y overrides m(), and calls W::m() to define v W -v m() X Y Overrides, calls W -v m() X Y Overrides, calls Overrides X::m() is added later Y:m() can no longer call W::m()!

Introduction to Software Testing (Ch 7), © Ammann and Offutt 25 Section 7.1 Outline 1.Overview 2.Types of Object-Oriented Faults 1.Example 2.The Yo-Yo Graph and Polymorphism 3.Categories of Inheritance Faults 4.Testing Inheritance, Polymorphism and Dynamic Binding 5.Object-Oriented Testing Criteria Testing Inheritance, Polymorphism and Dynamic Binding

Introduction to Software Testing (Ch 7), © Ammann and Offutt 26 Coupling Sequences n Pairs of method calls within body of method under test: –Made through a common instance context –With respect to a set of state variables that are commonly referenced by both methods –Consists of at least one coupling path between the two method calls with respect to a particular state variable n Represent potential state space interactions between the called methods with respect to calling method n Used to identify points of integration and testing requirements

Introduction to Software Testing (Ch 7), © Ammann and Offutt 27 Types of Def-Use Pairs def use A () intra-procedural data flow (within the same unit) def A() use B() A() B() F () object-oriented direct coupling data flow inter-procedural data flow def A () B () use last-def A () first-use B () full coupling object-oriented indirect coupling data flow def A() use B() M () N() F() A() M() B() N()

Introduction to Software Testing (Ch 7), © Ammann and Offutt 28 Coupling-Based Testing n Test data and control connections n Derived from previous work for non-procedural programs n Based on insight that integration occurs through couplings among software artifacts Caller F x = 14 y = G (x) print (y) print (a) b = 42 return (b) G (a) Callee last-def-before- return last-def-before-call first-use-in-callee call site first-use-after-call

29 Introduction to Software Testing (Ch 7), © Ammann and Offutt Polymorphic Call Set Set of methods that can potentially execute as result of a method call through a particular instance context pcs(o.m) = {W::m, Y::m, X::m} public void f ( W o ) { … j o.m(); … l o.l(); … k o.n(); }

Introduction to Software Testing (Ch 7), © Ammann and Offutt 30 o bound to instance of W h def (o) Client f i o.m() j o.l() k o.n() n () use (W::v) use (W::u) m () def (W::v) l () def (W::u) Example Coupling Sequence W -v : -u : +m() +n() +l() Z +m() +n() X -x : +n() Y -w : +m() +l() Coupling sequence with respect to W::v Coupling sequence with respect to W::u

Introduction to Software Testing (Ch 7), © Ammann and Offutt 31 o bound to instance of Z h def (o) Client f i o.m() j o.l() k o.n() m () def (Z::x) n () use (Z::x) l () def (W::u) Example Coupling Sequence (2) Coupling sequence with respect to Z::x W -v : -u : +m() +n() +l() X -x : +n() Y -w : +m() +l() Z +m() +n() -x :

Introduction to Software Testing (Ch 7), © Ammann and Offutt 32 Section 7.1 Outline 1.Overview 2.Types of Object-Oriented Faults 1.Example 2.The Yo-Yo Graph and Polymorphism 3.Categories of Inheritance Faults 4.Testing Inheritance, Polymorphism and Dynamic Binding 5.Object-Oriented Testing Criteria Object-Oriented Testing Criteria

Introduction to Software Testing (Ch 7), © Ammann and Offutt 33 Testing Goals n We want to test how a method can interact with instance bound to object o: –Interactions occur through the coupling sequences n Need to consider the set of interactions that can occur: –What types can be bound to o? –Which methods can actually execute? (polymorphic call sets) n Test all couplings with all type bindings possible

Introduction to Software Testing (Ch 7), © Ammann and Offutt 34 All-Coupling-Sequences n At least one coupling path must be executed n Does not consider inheritance and polymorphism All-Coupling-Sequences (ACS) : For every coupling sequence S j in f(), there is at least one test case t such that there is a coupling path induced by S j,k that is a sub-path of the execution trace of f(t)

Introduction to Software Testing (Ch 7), © Ammann and Offutt 35 All-Poly-Classes n Includes instance contexts of calls n At least one test for every type the object can bind to n Test with every possible type substitution All-Coupling-Classes (APC) : For every coupling sequence S j,k in method f(), and for every class in the family of types defined by the context of S j,k, there is at least one test case t such that when f() is executed using t, there is a path p in the set of coupling paths of S j,k that is a sub-path of the execution trace of f(t)

Introduction to Software Testing (Ch 7), © Ammann and Offutt 36 All-Coupling-Defs-Uses n Every last definition of a coupling variable reaches every first use n Does not consider inheritance and polymorphism All-Coupling-Defs-Uses (ACDU) : For every coupling variable v in each coupling S j,k of t, there is a coupling path induced by S j,k such that p is a sub-path of the execution trace of f(t) for at last one test case t

Introduction to Software Testing (Ch 7), © Ammann and Offutt 37 All-Poly-Coupling-Defs-and-Uses n Combines previous criteria n Handles inheritance and polymorphism n Takes definitions and uses of variables into account All-Poly-Coupling-Defs-and-Uses (APDU) : For every coupling sequence S j,k in f(), for every class in the family of types defined by the context of Sj,k, for every coupling variable v of Sj,k, for every node m that has a last definition of v and every node n that has a first-use of v, there is at least one test case t such that when f() is executed using t, there is a path p in the coupling paths of Sj,k that is a sub-path of the trace of f()

Introduction to Software Testing (Ch 7), © Ammann and Offutt 38 OO Coverage Criteria Subsumption All-Coupling- Sequences ACS All-Poly-Coupling Defs-Uses APDU All-Poly- Classes APC All-Coupling- Defs-Uses ACDU

Introduction to Software Testing (Ch 7), © Ammann and Offutt 39 Conclusions n A model for understanding and analyzing faults that occur as a result of inheritance and polymorphism n Technique for identifying data flow anomalies in class hierarchies n A fault model and specific faults that are common in OO software n Results are under consideration by the FAA for defining standards for testing of OO software for avionics applications