Software Testing and Quality Assurance

Slides:



Advertisements
Similar presentations
Construction process lasts until coding and testing is completed consists of design and implementation reasons for this phase –analysis model is not sufficiently.
Advertisements

Design by Contract.
Copyright W. Howden1 Programming by Contract CSE 111 6/4/2014.
Software Engineering of Standalone Programs University of Colorado
Design by Contract. Design by contract is the process of developing software based on the notion of contracts between objects, which are expressed as.
1 Design by Contract Building Reliable Software. 2 Software Correctness Correctness is a relative notion  A program is correct with respect to its specification.
Feb 2003 R McFadyen1 Contracts (Ch 13) Used to help understand requirements more completely based on assertions; assertions are applicable to any.
Introduction To System Analysis and Design
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
1 Software Testing and Quality Assurance Lecture 12 - The Testing Perspective (Chapter 2, A Practical Guide to Testing Object-Oriented Software)
Software Testing and Quality Assurance
1 Software Testing and Quality Assurance Lecture 21 – Class Testing Basics (Chapter 5, A Practical Guide to Testing Object- Oriented Software)
1 Software Testing and Quality Assurance Lecture 10 - The Testing Perspective (Chapter 2, A Practical Guide to Testing Object-Oriented Software)
Jan 2005 Ron McFadyen1 Contracts Used to help understand requirements more completely (and so may not always be necessary) based on assertions;
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)
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Static and Dynamic Contract Verifiers For Java Hongming Liu.
1 Software Testing and Quality Assurance Lecture 28 – Testing Class Hierarchies.
November 13, 2006ECEN 5543 / CSCI 5548 – Testing OO University of Colorado, Boulder 1 Testing Object-Oriented Software Principles Summary ECEN 5543 / CSCI.
16/22/2015 2:54 PM6/22/2015 2:54 PM6/22/2015 2:54 PMObject-Oriented Development Concept originated with simulating objects and their interactions. Adapted.
1 Software Testing and Quality Assurance Lecture 20 – Class Testing Basics (Chapter 5, A Practical Guide to Testing Object- Oriented Software)
Page 1 Building Reliable Component-based Systems Chapter 6 - Semantic Integrity in Component Based Development Chapter 6 Semantic Integrity in Component.
September 2002 R McFadyen1 Domain Model Use Case Model text diagram SSD System operation contracts Design Model Figure 13.3.
Eiffel Language and Design by Contract Contract –An agreement between the client and the supplier Characteristics –Expects some benefits and is prepared.
Chapter 10 Classes Continued
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.
Object-Oriented Analysis and Design
Computer Science 340 Software Design & Testing Design By Contract.
Ranga Rodrigo. Class is central to object oriented programming.
Programming Languages and Paradigms Object-Oriented Programming.
Classes and Class Members Chapter 3. 3 Public Interface Contract between class and its clients to fulfill certain responsibilities The client is an object.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
Introduction To System Analysis and Design
An Introduction to Java Chapter 11 Object-Oriented Application Development: Part I.
CSE 425: Object-Oriented Programming I Object-Oriented Programming A design method as well as a programming paradigm –For example, CRC cards, noun-verb.
SWE 619 © Paul Ammann Procedural Abstraction and Design by Contract Paul Ammann Information & Software Engineering SWE 619 Software Construction cs.gmu.edu/~pammann/
Low-Level Detailed Design SAD (Soft Arch Design) Mid-level Detailed Design Low-Level Detailed Design Design Finalization Design Document.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 13 Introduction to Classes.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
1 Chapter 8 – Classes and Object: A Deeper Look Outline 1 Introduction 2 Implementing a Time Abstract Data Type with a Class 3 Class Scope 4 Controlling.
Chapter 16 Applying UML and Patterns Craig Larman
ADTs and C++ Classes Classes and Members Constructors The header file and the implementation file Classes and Parameters Operator Overloading.
An Object-Oriented Approach to Programming Logic and Design Chapter 3 Using Methods and Parameters.
Chapter 10 Defining Classes. The Internal Structure of Classes and Objects Object – collection of data and operations, in which the data can be accessed.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
Chapter 10 Classes and Objects In-Depth. Chapter 10 A class provides the foundation for creating specific objects, each of which shares the general attributes,
CSci 162 Lecture 10 Martin van Bommel. Procedures vs Objects Procedural Programming –Centered on the procedures or actions that take place in a program.
Chapter 16: UML Class Diagrams
SWE 4743 Abstract Data Types Richard Gesick. SWE Abstract Data Types Object-oriented design is based on the theory of abstract data types Domain.
CMSC 345 Fall 2000 OO Design. Characteristics of OOD Objects are abstractions of real-world or system entities and manage themselves Objects are independent.
PROGRAMMING PRE- AND POSTCONDITIONS, INVARIANTS AND METHOD CONTRACTS B MODULE 2: SOFTWARE SYSTEMS 13 NOVEMBER 2013.
CSSE501 Object-Oriented Development. Chapter 10: Subclasses and Subtypes  In this chapter we will explore the relationships between the two concepts.
Chapter 7 Programming by contract: preconditions and postconditions.
Fusion Design Overview Object Interaction Graph Visibility Graph Class Descriptions Inheritance Graphs Fusion: Design The overall goal of Design is to.
DBC NOTES. Design By Contract l A contract carries mutual obligations and benefits. l The client should only call a routine when the routine’s pre-condition.
Object Design More Design Patterns Object Constraint Language Object Design Specifying Interfaces Review Exam 2 CEN 4010 Class 18 – 11/03.
Object Oriented Programming and Data Abstraction Earl Huff Rowan University.
CPSC 252 ADTs and C++ Classes Page 1 Abstract data types (ADTs) An abstract data type is a user-defined data type that has: private data hidden inside.
Interfaces CMSC 202. Public Interfaces Objects define their interaction with the outside world through the their public interface. A class' public interface.
Design by Contract Jim Fawcett CSE784 – Software Studio
Design by Contract Jim Fawcett CSE784 – Software Studio
Used to help understand requirements more completely
Design by contract Object-Oriented Software Construction by Bertrand Meyer, Prentice Hall The presence of a precondition or postcondition in a routine.
Design by contract Object-Oriented Software Construction by Bertrand Meyer, Prentice Hall The presence of a precondition or postcondition in a routine.
Computer Science 340 Software Design & Testing
Classes and Objects Systems Programming.
Design Contracts and Errors A Software Development Strategy
Presentation transcript:

Software Testing and Quality Assurance Lecture 11 - The Testing Perspective (Chapter 2, A Practical Guide to Testing Object-Oriented Software)

Lecture Outline Testing perspective -Object-Oriented Concepts Interface Class

Interface - Testing Perspective An interface is an aggregation of behavioral declarations. An interface is a building block for specifications. In java: interface In C++: by declaring abstract class with only public, pure virtual methods.

Interface - Testing Perspective Interface encapsulates operation specifications. Theses specifications incrementally build the specifications of large groupings such as classes. Interface has relationships with other interfaces and classes. Testers perspective: Relationship between interfaces.

Interface - Testing Perspective- Example For example, an interface might describe a set of behaviors related to being a moving object. public interface Movable { public Point getsPosition (): public Velocity getVelocity(); public void mover(); }

Class - Testing Perspective A class is a set of objects that share a common conceptual bases (a template for creating objects). Objects form the basic element for executing OO programs While classes form the basic elements for defining OO programs.

Class - Testing Perspective Instantiation: the process of creating an object. Instance (object): the result of instantiation. The conceptual basis common to all the objects in a class is expressed in terms: A class specification: what each object can do (C++ header file). A class implementation: how each object do what they can do.

Class Specifications Class Specifications Describes what the class represents and what an instance of the class can do. An operation is an action that can be applied to an object to obtain a certain effect: Accessor (or inspector) operation: provide information about an object. For example, value of some attribute (in C++, const) Modifier operations: change the state of an object by setting one or more attributes to have new values.

Class Specifications Other types of operations: A constructor is a class object operation used to create a new object including the initialization of the new instance when it comes into existence. A destructor is an instance object operation used to perform any processing needed just prior to the end of an object’s lifetime.

Class Specifications Semantics can be specified at several different points: Preconditions: conditions that must hold before the operation is performed. Postconditions: conditions that must hold after the operation is performed. Invariants: conditions that must always hold within the life time of the object. Implied post-condition for each operation. Testers care about Preconditions, post-conditions, invariants Relation to other classes (interactions)

Class Specifications To write specification for an operation, two basic approaches can be used to define the interface between the receiver and the sender: Design by contract approach. Defensive programming approach. Each approach has a set of rules about how to define the constraints and the responsibilities for the sender and receiver when an operation to be performed.

Class Specifications - Contract Design by contract: A contract between the sender and receiver of a message. The sender is responsible for ensuring the preconditions are met. The receiver is responsible for ensuring post-conditions are met and maintaining class invariants. Testers care about how this contract is enforced. Language support: iContract

Class Specifications - Contract Pre and Postcondition - Summary Client (i.e. caller) Supplier (i.e. method) Obligation Must ensure precondition (i.e. correct input parameter) Must ensure post-condition (i.e. method works correctly) Benefit Need not ensure post-condition (i.e. special values or exceptions Need not ensure precondition (i.e. validity of input parameters), although it needs to check it before it runs.

Class Specifications - Contract p binds the client A. It is an obligation for A but a benefit for B. q binds the supplier B. It is an obligation for B but a benefit for A. Class B m(x); contract Class A pre: p post: q Class B says to its clients: “If you promise to call m with p satisfied, then I, in return, promise to deliver a final state in which q is satisfied.”

Class Specifications - Contract double sqrt (double x) require x >= 0 do … ensure result * result == x end Design by contract example: The same example using iContract syntax: //** return Square root of x @pre x >= 0 @post return * return == x */ double sqrt (double x) { … }

Defensive programming Interface is defined primarily in terms of the receiver. An operation returns some indication concerning the status of the result of the request (success or failure) in terms of return code. The receiver can provide the sender an object that encapsulates the status of the request. Exceptions are used frequently.

Defensive programming The goal is to identify “garbage in” and hence eliminate “garbage out”. A member function checks for the improper values coming in and then report that status of the request to the sender.

Defensive programming This approach increases the complexity of the software. Each sender must follow a request for an operation with code to check the processing status and then; for each possible outcome, provide code to take an appropriate recovery action. Testers care about how the receiver ensures pre and post-conditions.

Defensive programming Defensive programming example using assert: void test( int *p ) { assert( p != 0 ); if (p == 0) return; // use p. }

Class Specifications Contract vs. defensive programming: The contract approach simplifies class testing, but complicates interaction testing because we must ensure any sender meets preconditions. The defensive programming approach complicates both class testing (test cases must address all possible outcomes); and interaction testing (we must ensure all possible outcomes are produced and that they are properly handled by a sender).

Class Implementation Class implementation describes how an object represents its attributes and carries out operations. It compromises several components: A set of data values stored in data members (instance variables or variables). A set of methods (member functions in C++ or methods in Java) constitutes code that will be used to implement an algorithm that accomplishes one operation declared in the public or private class specification.

Class Implementation – Testing Perspective From testing perspective, potential causes of failures within class design and implementation: A class specification contains operations to construct instances. These operations may not properly initialize the attributes of the new instances. A class relies on collaboration with other classes to define its behaviors and attributes. These other classes may be implemented incorrectly. A class’ implementation “satisfies” its specification, but that is no guarantee that the specification is correct. The implementation might not support all required operations or may incorrectly perform operations. A class specifies preconditions to each operation. The class may not provide a way for the precondition to be checked by a sender before sending a message.

Class Implementation The design approach used gives rise to different sets of potential problems: In contract approach we only need to test situations in which the precordinations are satisfied. In defensive programming approach we must test every possible input to determine that the outcome is handled properly.

Key points Object-oriented concepts: interface class (specification and implementation)

Announcements Help Session Major 1 on Sat November 8, 2008 Wednesday or Thursday What time is suitable for everyone? Major 1 on Sat November 8, 2008