Top Banner
CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 [email protected] et
103
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

CSE 7314Software Testing and Reliability

Robert Oshana

Lecture 20

[email protected]

Page 2: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Introduction

Chapter 1

Page 3: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Introduction

• Testing - Challenging but understood– Unit, integration, system, acceptance

• Testing OO systems– “the same, only different” ;-)

• We’ll talk about testing OO systems throughout the development cycle

• Testing is the process of uncovering evidence of defects in software systems

Page 4: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Introduction

• Bug; a mistake, misunderstanding, omission, or misguided intent on the part of the developer

• Testing is the process of finding defects

• Testing does NOT include efforts to track down bugs and fix them (e.g. debugging or repair of bugs)

Page 5: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Introduction

• Testing; making sure an application does everything it is supposed to do and nothing that it is not supposed to do

• Guards against time, property, customers, life

Page 6: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

What is software?

• Instruction codes and data necessary to accomplish a task on a computer

• Also all representations of those instructions and data– Models created during analysis/design

Page 7: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

What is software?

• Testing is not quality assurance

• Testing is a necessary but insufficient part of a quality assurance program

• QA; prevention and well as removal

• Testing will not necessarily improve the quality of a computer program

Page 8: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Testing OO systems

• OO features impact testing– Class inheritance– Interfaces/polymorphism– Language features to support data hiding

impact testing• Operation must be added just to support testing• Can also support more reusable testing software

• Many approaches have counterparts in traditional testing

Page 9: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Testing OO systems

• With an OO approach, a program’s design is structured from the problem, and not from the immediately required solution

• Analysis models map straightforward to design models that map to code

• Can therefore start testing during analysis, and refine during design and implementation

Page 10: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Advantages to testing analysis and design models• Test cases can be identified earlier in

the process• Bugs can be detected early in the

development process• Test cases can be reviewed early in

the process for correctness• Testing can also be used to check

designs for reusability and scalability

Page 11: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Overview of testing approach

• Time and money constraints must be real concern

• Test early, test often, test enough– Analyze a little– Design a little– Code a little– Test what you can

Page 12: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Testing for OO software

• Model testing• Class testing, which replaces unit

testing• Interaction testing, which replaces

integration testing• System (and subsystem) testing• Acceptance testing• Deployment/self testing

Page 13: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Test early

• Start testing at reasonable points during the analysis and design phases of a project

• Can uncover problems when they are easier and cheaper to fix

• Can help scope the size of the effort for system testing

• SW representations are abstract and/or incomplete

Page 14: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Test often

• Incremental or iterative development should require testing at each increment

• After first increment, some testing is in the form of regression testing

Page 15: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Test enough

• Complete testing of every aspect of a software system is infeasible

• Resources should be directed where they have the greatest impact

• Tests should be based in risk analysis, reuse of test cases, and statistical sampling of inputs for test cases

Page 16: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

The testing perspective

Page 17: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Testing perspective

• A way of looking at the development product and questioning its validity

• Search for faults both systematic as well as intuitive insight

• Reviews; almost never find something that is missing– Validates what exists– No systematic search to determine things that

should be in are actually in

Page 18: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Testing perspective

• Software must execute according to spec and only that spec– Make sure it does what it is supposed to

do– Does not do what it is not supposed to

do

• Can be performed by same developer or independent view

Page 19: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Review, inspection, execution

• Inspection; examination of SW based on checklist of typical problems– Most based on programming language

semantics or coding conventions• Program variables initialized• Pointers or references set correctly

– Modern compilers can find many of these

Page 20: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Review, inspection, execution

• Review; examination of SW to find faults before the SW is executed• Delves into the meaning of each part of

a program• Missed or misunderstood requirements

or faults in the program’s logic• Whether variables are well chosen• Whether algorithms are as efficient as

they could be

Page 21: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Review, inspection, execution

• Test execution; testing SW in the context of a running program• Tester tries to determine whether it has

the required behavior by giving the program some input and verifying that the resulting output is correct

• Challenge is to identify suitable inputs, determining correct outputs, and how to observe the outputs

Page 22: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Testing perspective

• Skeptical; what proof of quality

• Objective; make no assumptions

• Thorough; don’t miss important areas

• Systematic; searches are reproducible

Page 23: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Object-Oriented Concepts

• Object

• Message

• Interface

• Class

• Inheritance

• Polymorphism

Page 24: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Object

• An operational entity that encapsulates both specific data values and the code that manipulates those values

• Basic computational entity• Objects are created, modified,

accessed and/or destroyed as a result of collaborations

Page 25: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Object

• A representation of some specific entity in a program or in its solution

• Objects are the direct target of the testing process– Behaves according to specification– Interacts appropriately with

collaborating objects

Page 26: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Observations

• Objects encapsulate; makes the complete definition of the object easy to identify; easy to pass around in the system; and easy to manipulate

• Objects hide information; changes to the object sometimes hard to observe, makes checking of test results difficult

Page 27: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Observations

• Object has a state that persists for the life of the object; state can become inconsistent and can be the source of incorrect behavior

• Object has a lifetime; can be examined at various points in the lifetime to determine if in appropriate state based on lifetime (construction too late or destruction too early are common sources of failures)

Page 28: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Message

• A request that an operation be performed by some object

• Includes – Name of the operation– Actual parameters

• Collaboration achieved by sending messages– Sender and receiver

Page 29: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Observations

• Message has a sender; sender determines when to send the message (may make incorrect decision)

• Message has a receiver; may not be ready for the specific message it receives, or receiver may not make correct action when receiving unexpected message

Page 30: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Observations

• Message may include actual parameters; used and/or updated by the receiver while processing the message

• Objects passed as parameters must be in correct states before and after message is processed

• Must implement interfaces expected by the receiver

Page 31: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Object-Oriented concepts

• Interface; aggregation of behavioral declarations

• Grouped to define actions related to a single concept

• A building block for specifications which define to total set of public behaviors for a class

Page 32: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Interface example

public interface Movable {public Point getPosition( );public Velocity getVelocity( );public void setVelocity(Velocity newVelocity);public void tick( );public void move( );public void collideWith(ArcadeGamePiece aPiece, Point aPoint);public void collideWithPaddle(Paddle aPaddle, Point aPoint);public void collideWithPuck(Puck aPuck, Point aPoint);public void reverseY( );public void reverseX( );

}

Page 33: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Observations

• Interfaces encapsulate operation specifications

• These specifications incrementally build the specifications of larger grouping such as classes

• I/F must contain appropriate behaviors or leads to unsatisfactory designs

• I/F has relationships with other I/Fs and classes and may be specified as a parameter type for a behavior

Page 34: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Object-Oriented concepts

• Class; a set of objects that share a common conceptual basis

• A template or “cookie cutter” to create objects

• Classes are the basic elements for defining OO programs while objects are the basic elements for executing OO programs

• Create by instantiation

Page 35: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Object-Oriented concepts

• Class specification; declaration of what each of the objects can do

• Class implementation; definition of how each of the objects in the class do what they can do

Page 36: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Example class specification#ifndef PUCKSUPPLY_H#define PUCKSUPPLY_HClass PuckSupply {Public:

PuckSupply( );~PuckSupply( );

Puck* get( );int size( ) const;

Private:static const int N = 3;int_count;Puck* _store[N];

};#endif

WHAT …

Page 37: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Example class implementation

#include “PuckSupply.h”PuckSupply::PuckSupply( ) : _count(N) {

int i;for ( i=0; i<N; i++) {

_store[ i ] = new Puck;};

}PuckSupply:: int i;

for ( i=0; i<N; i++) {delete _store[ i ];

};}

Puck* PuckSupply::get( ) {return (_count > 0 ? _store[--count] : 0 );

}…..

HOW …

Page 38: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Class specification

• Must be a specification for each operation– Accessor (inspector) operations– Modifier (mutator) operations– Constructor– Destructor

Page 39: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Operation semantics

• Well specified operation semantics are critical to both development and testing– Preconditions– Postconditions– Invariants

Page 40: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Approaches to defining an interface

• Contract approach; emphasizes preconditions and has simpler postconditions

• Defensive programming; emphasizes postconditions and has simpler preconditions (I/F defined in terms of the receiver)– Goal is to define “garbage in” and

eliminate “garbage out”

Page 41: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Class implementation

• A class implementation describes how an object represents its attributes and carries out operations– Set of data values stored in data members– Set of methods– Constructors– Destructors– Private operations

Page 42: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Class testing

• Class testing is important because they define the building blocks for OO programs

• Potential causes of failures– Class spec contains operations to

construct instances that may not properly initialize attributes of new instances

Page 43: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Class testing

– Class relies on collaboration with other classes that may not be implemented correctly and contribute to the failure of the class using the definition

– Class implementation satisfies the spec but the spec may be wrong

– Implementation might not support all required operations or may incorrectly perform operations

Page 44: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Class testing

– Class specifies preconditions to each operation but the class may not provide a way for the precondition to be checked by a sender before sending a message

• The design approach used (contract or defensive) gives rise to different sets of problems

Page 45: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

A word on abstraction

• The process of removing detail from a representation

• Allows us to look at a problem or its solution in various levels of detail

• Can leave out any details that are irrelevant to the current level of interest

• OO technologies make extensive use of this

Page 46: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

A word on abstraction

• From a testing perspective, layers of abstraction in the development process are paralleled by layers of test analysis

• Start with the highest levels of abstraction and provide a more thorough examination of the development product with more accurate tests

Page 47: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Inheritance

• This is a relationship between classes that allows the definition of a new class based on the definition of an existing class– Reuse of specification and

implementation– Preexisting class does not have to be

modified

Page 48: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Inheritance

• Good OO design uses inheritance for is a (is a kind of) relationship

• Best use is with respect to specification and implementation

Page 49: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Inheritance from a testing perspective

• Provides a mechanism by which bugs can be propagated from a class to its descendents – Testing a class as it is developed eliminates

faults early before they are passed to other classes

• Provides a mechanism to reuse test cases– Can reuse test cases from superclass to test

subclass

Page 50: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Inheritance from a testing perspective

• Models an is a kind of relationship– Inheritance solely for code reuse leads

to maintenance difficulties– Testers can check to make sure

inheritance is used correctly

Page 51: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Polymorphism

• The ability to treat an object as belonging to more than one type

• More typing systems support designs that are flexible and easy to maintain

Page 52: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Inclusion polymorphism

• The occurrence of different forms in the same class

• Provides the ability to substitute an object whose spec matches another object’s spec for the latter object in a request for an operation– Sender can use an object as a

parameter based on its implementation of an I/F rather than its full class

Page 53: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Set diagram for a Brick inheritance hierarchy

Brick

HardBrick PowerBrick

Page 54: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Abstract class

• A class whose purpose is primarily to define an interface that is supported by all of its descendents

• Use of abstractions allows polymorphism to be exploited during design

Page 55: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Set diagram for a Brick class inheritance hierarchy

Brick

HardBrick PowerBrick

PlainBrick

Page 56: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

10 minute break

Page 57: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

CSE 7314Software Testing and Reliability

Robert Oshana

Lecture 21

[email protected]

Page 58: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Inclusion polymorphism testing perspective

• Inclusion polymorphism allows systems to be extended incrementally by adding classes rather than modifying existing ones– Unanticipated interactions can occur in

the extensions

Page 59: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Inclusion polymorphism testing perspective

• Inclusion polymorphism allows any operation to have one or more parameters of a polymorphic reference• This increases the number of possible

kinds of actual parameters that should be used

Page 60: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Inclusion polymorphism testing perspective

• Inclusion polymorphism allows an operation to specify replies that are polymorphic references• The actual class of the referent could be

incorrect or unanticipated by the sender

Page 61: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Inclusion polymorphism testing perspective

• The dynamic nature of object-oriented languages places more importance on testing a representative sample of runtime configurations• Static analysis can provide the potential

interactions that might occur, but only runtime configuration can illustrate what actually happens

Page 62: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Parametric polymorphism

• The capability to define a type in terms of one or more parameters

• Templates in C++ provide a compile time capability to instantiate a “new” class– Actual parameter is provided for the

formal parameter in the definition

Page 63: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

C++ List class template

template<class ItemType, class Key>class List{public:

void add(ItemType* item);ItemType* retrieve(Key searchValue);

}

Page 64: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Testing perspective

• Parametric polymorphism supports a different type of relationship from inheritance

• If the template works for one instantiation, there is no guarantee that it will work for another!– Template code might assume the correct

implementations of operations such as destructors

– Should be checked during inspection

Page 65: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Development products

Chapter 2

Page 66: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Development products

• Good documentation is critical for successful development and testing

• A collection of work products that represent the system and the requirements

• UML is an example of a conceptual modeling language

• C++ is the programming language

Page 67: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

SW end products

• Code and documentation– User manuals– Maintenance documents

• Analysis and design models• Architectural models• Quality requirements

• UML is used to generate these models

Page 68: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Analysis models

Page 69: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Analysis models

• Purpose of analysis is to define the problem to be solved and to determine requirements for a solution to that problem– Domain analysis; focuses on

understanding the problem– Application analysis; focus is on

specific problem and requirements for a solution (more concrete concepts)

Page 70: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Analysis models

• Represents a system from the perspective of what it is supposed to do

• Provides an understanding of the problem and requirements

Page 71: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Use case diagram

• A use case describes a use of the system by an actor to perform some task

• Actors represent roles users play with respect to the system

• Can be expressed at various levels of abstraction

Page 72: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Domain level use cases for arcade games

Name Description

Start a player starts a match

Pause a player pauses a match

Resume a player resumes playing a match

Stop a player stops a match

Page 73: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Application level use cases for Brickles arcade game

Name Description

Start Brickles a player starts playing Brickles by starting the application program under Windows

Pause Brickles a player pauses a Brickles match by pressingthe mouse button

Resume Brickles a player resumes a Brickles match by releasing the mouse button

Move Paddle a player moves the mouse right or left to movethe paddle left or right

Page 74: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Use case hierarchy

• Two hierarchy relationships– Uses; to create more specific use cases– Extends; helps to organize a potentially large

number of use cases

• Use cases represent requirements not software

• Scenario shows a particular application or instantiation of a use case

Page 75: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Use cases for Brickles

Play Brickles

Pause Brickles

Stop Brickles

Break Brick

Move Paddle

Lose Paddle

Win

Lose

<<extends>>

<<extends>>

<<extends>>

<<extends>>

<<extends>>

Page 76: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Class diagrams

• Presents a static view of a set of classes and the relationships between the classes

• Operations, attributes, constraints on relationships shown

Page 77: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Applicationanalysis classdiagramforBrickles

Page 78: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Package diagram

• Groups of classes can be represented as a package

• Allows easy reuse in the future

• Dependencies can be shown

Page 79: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Package diagram

Page 80: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

State diagrams

• Describes the behavior of the objects in a class in terms of its observable states and how the object changes states as a result of events that affect the object– State; particular configuration of the

values of data attributes– Transition; a change from one state to

another

Page 81: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

State diagrams

– Event; a message arrival– Guard; a condition that must hold

before the transition can be made– Action; specifies processing to be done

while a transition is in progress– Concurrent state diagram can show

groups of states that reflect the behavior of an object from the perspective of two or more independent ways

Page 82: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

State diagram for class Timer

Page 83: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Class specification

• An approach to detail the semantics associated with each operation

• Object Constraint Language (OCL) is a specification technique used for this purpose

• Constraints involve– Attributes– Operations– Associations

Page 84: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

OCL for operations of PuckSupply

PuckSupplysize >= 0 and size <= 3

PuckSupply:: PuckSupply( )pre: - nonepost: size = 3 AND pucks->forAll( puck: Puck | not puck.inPlay( ) )PuckSupply:: ~PuckSupply( )pre: - nonepost: Puck->size( ) = Puck@pre->size( ) – size@prevoid PuckSupply:: size( ) constpre: - nonepost: result = sizePuck * PuckSupply::get( )pre: count > 0post: result = pucks->asSequence->first AND size = size@pre - 1

Page 85: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Sequence diagram

• Captures the messaging between objects, object creation, and replies from messages

• Illustrate process in domain– How common tasks are carried out through the

interaction of objects in a scenario

• Various levels of abstraction• Can represent concurrency

Page 86: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Sequence diagrams for Brickles

Page 87: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Activity diagram

• Where sequence diagrams capture single traces through a set of object interactions, it is difficult to represent iteration and concurrency

• Activity diagram provides a more comprehensive representation– Flow chart– Petri nets

Page 88: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Activity diagram for move() method in Puck

Page 89: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Activity diagram

Page 90: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Design models

Page 91: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Design models

• Represent how the software meets requirements

• Refinements and extensions of the analysis models

• Means we can reuse and extend test cases developed for analysis models

• Focus on solution rather than the problem

Page 92: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Class diagram

• Depicts the kinds of objects that will be created by the software

• Name, attributes, operations, relationships

• Adds detail to the analysis class diagram

• Maintains most of the structure and adds detail for the solution

Page 93: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Design classdiagram forBrickles

Page 94: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

State diagram

• Same as those used in analysis

• Add state diagrams for new classes in the design class diagram and potentially new substates

• More actions and activities may be shown

Page 95: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

State diagram

• Should ensure test cases for a class that adequately transitions between states and provides proper processing of messages between states

• Possible to reuse some test cases and test drivers that were developed for testing other classes whose design is based on the same pattern

Page 96: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

State diagram for class Timer

Page 97: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Sequence diagrams

• Used in design to describe algorithms• Difference from analysis is the presence

of solution level objects in the design diagram

• Testing perspective; possible errors are violation of contracts, failure to create objects of the correct class, sending of messages for which no navigation is indicated between sender and receiver

Page 98: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Sequence diagram for start-up for a Brickles match

Page 99: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Source code

• Source code is the final representation for software

• Translator makes software executable

• Should be an accurate translation from design models but must be tested

Page 100: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Source code

• Testing actual code is traditional focus

• Test as developed as well as completed product

• Major issues include– Who tests?– What is tested?

Page 101: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Source code

• Major issues include– When testing is done?– How testing is done?– How much testing is done?

Page 102: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

Testing and programming language

• Programming language has an impact on testing– Enabling of certain types of error– Strong vs weak typing implies more or

less errors caught by compiler– Pointer and memory problems– Data hiding– Interface testing

Page 103: CSE 7314 Software Testing and Reliability Robert Oshana Lecture 20 oshana@airmail.net.

End of lecture