Software Testing w4 - Watermark
Software Testing w4 - Watermark
1
Integration Testing Approaches
• Develop the integration plan by
examining the structure chart :
–big bang approach
–top-down approach
–bottom-up approach
–mixed approach 2
Example Structured Design
M1
M2 M3 M4
M5 M6 M7 M7
M8
3
Big Bang Integration Testing
• Big bang approach is the simplest
integration testing approach:
M2 M3 M4
M5 M6 M7 M7
M8
7
Example Bottom-up Testing
M1 In Bottom Up testing :
– M5-M8 is tested
M2 M3 M4
with drivers for M5
M7
– M5-M6-M8 is
M5 M6 M7
tested with drivers
for M5-M6
M8
–…
8
Top-down Integration Testing
• Top-down integration testing starts with the
top module:
M2 M3 M4
M5 M6 M7 M7
M8
10
Top-down Integration Testing
• In Top Down test:
M1
– M1-M2 tested with
stubs for M3, M4, M5
M2 M3 M4
and M6
M7 M8 – M1-M2- M3 tested
M5 M6
with stubs for M4
M5, and M6
M8
– Then M1-M2-M3-M4
tested with stubs for
11
M5, M6, M7 and M8
Top-Down Integration
• Advantages of top down integration testing:
– Test cases designed to test the integration of
some module are reused after integrating other
modules at lower level.
– Advantageous if major flaws occur toward the
top of the program.
• Disadvantages of top down integration testing:
– It may not be possible to observe meaningful
system functions because of an absence of lower
level modules which handle I/O.
– Stub design become increasingly difficult when12
stubs lie far away from the level of the module.
Mixed Integration Testing
• Mixed (or sandwiched)
integration testing:
M2 M3 M4
M5 M6 M7 M7
M8
14
Integration Testing
• In top-down approach:
–Integration testing waits till all
top-level modules are coded and
unit tested.
• In bottom-up approach:
–Testing can start only after
bottom level modules are ready. 15
System Testing
• Objective:
–Validate a fully developed
software against its
requirements.
16
System Testing
• There are three main types of
system testing:
–Alpha Testing
–Beta Testing
–Acceptance Testing
17
Alpha Testing
• System testing carried out by
the test team within the
developing organization.
19
Acceptance Testing
• System testing performed by
the customer himself:
21
Types of System Testing
• Two types:
– Functionality: Black-box test cases
are designed to test the system
functionality against the requirements.
31
Recovery Testing
37
Test Summary Report
• Specifies:
– how many tests have been applied to a
subsystem,
– how many tests have been successful,
– how many have been unsuccessful, and the
degree to which they have been
unsuccessful,
• e.g. whether a test was an outright failure
• or whether some expected results of the test
38
were actually observed.
Regression Testing
39
Latent Errors: How Many Errors are Still
Remaining?
• N = S n/s
• remaining defects:
N - n = n ((S - s)/ s)
42
Quiz 1
• 100 errors were introduced.
• 90 of these errors were found
during testing
• 50 other errors were also found.
• Find error estimate for the
code. 43
Quiz 1: Solution
• 100 errors were introduced.
• Remaining errors=
50 (100-90)/90 = 6
44
Error Seeding: An Issue
• The kinds of seeded errors should
match closely with existing errors:
–However, it is difficult to predict the
types of errors that exist.
• Working solution:
47
Why regression testing?
T2 T3 T4 T5
T1
b=b+5;
Program
a=a*b;
Failure
48
Need for Regression Testing
• Any system during use undergoes
frequent code changes.
– Corrective, Adaptive, and Perfective
changes.
• Regression testing needed after
every change:
– Ensures unchanged features continue
to work fine.
49
Partitions of an Existing Test Suite
To
Obsolete
Tu
Redundant
Tor Tr
Optimized Regression Tests
Regression
Tests
50
Automated Regression Testing
• Test cases that have already run once:
– May have to be run again and again after each
change
– Test cases may be executed hundreds of time
– Automation very important…
• Fortunately, capture and replay type tools appear
almost a perfect fit:
– However, test cases may fail for reasons such as
date or time change
– Also test cases may need to be maintained after
51
code change
Major Regression Testing Tasks
• Test revalidation (RTV):
– Check which tests remain valid
• Test selection (RTS):
– Identify tests that execute modified
portions.
• Test minimization (RTM):
– Remove redundant tests.
• Test prioritization (RTP):
52
Software Change
Analysis
Software Change
Impact Analysis
Select Regression
Tests
Run Regression
Tests at different levels
Report Retest
Results
53
Testing Object-
Oriented Programs
54
Quiz
• Is regression testing a unit, integration,
or system testing technique?
55
Introduction
• More than 50% of development effort is being
spent on testing.
• Quality and effective reuse of software depend
to a large extent:
– on thorough testing.
• It was expected during initial years that OO
would help substantially reduce testing effort:
– But, as we find it out today --- it only
complicates testing.
56
Challenges in OO Testing
• What is an appropriate unit for testing?
• Implications of OO features:
– Encapsulation
– Inheritance
– Polymorphism & Dynamic Binding, etc.
• State-based testing
• Test coverage analysis
• Integration strategies
• Test process strategy
57
What is a Suitable Unit
for Testing?
• What is the fundamental unit of testing for
conventional programs?
– A function.
• However, as far as OO programs are
concerned:
– Methods are not the basic unit of testing.
• Weyukar's Anticomposition axiom:
– Any amount of testing of individual
methods can not ensure that a class has
been satisfactorily tested.
58
Suitable Unit for Testing
OO Programs
• Class level:
– Testing interactions between
attributes and methods must be
addressed.
– State of the object must be
considered.
59
Weyukar’s Anticomposition Axion
(IEEE TSE Dec. 1986)
• Adequate testing of each individual program
components does not necessarily suffice to
adequate test the entire program.
• Consider P and Q as components:
– P has the opportunity to modify the context
seen by Q in a more complex way than could be
done by stubs during testing of components in
isolation.
63
Inheritance
• Should inherited methods be retested?
– Retesting of inherited methods is the rule,
rather than an exception.
LibraryMember Base Class
Derived
Faculty Students Staff
Classes
• Retesting required:
– Because a new context of usage results
when a subclass is derived.
(Anticomposition axiom)
65
Example
Class A{
Protected int x=200; //invariant x>100
Void m(){//correctness depends on
invariant}
}
Class B extends A{
void m1(){x=1; …} …}
• Execution of m1() causes a bug in m()
• Breaks the invariant, m is incorrect in the
context of B, even though it is correct in
A: 66
- Therefor m should be retested in B
Another Example
Class A{
Void m(){ … m2(); … }
Void m2() {…} }
Class B extends A{
void m2(){…} …}
• M2 has been overridden in B, can affect other
methods inherited from A such as m()
- m() would now call B. m2.
- So, we cannot be sure that m is correct
anymore, we need to retest it with B instance
67
Inheritance --- Overriding
• In case of method overriding:
– Need to retest the classes in
the context of overriding.
– An overridden method must be
retested even when only minor
syntactic changes are made.
68
Which Methods to Test Within A Class?
• New methods:
– Defined in the class under test not
inherited or overloaded by methods in a
super class:
– Complete testing
• Inherited methods:
– Defined in a superclass of the class under
test:
Retest only if the methods interacts with
new or redefined method.
• Redefined methods:
- Defined in a superclass of but redefined 69
class under test: complete Retest
Regression Testing Derived Class: Example
• Principle: inherited LibraryMember
Base Class
methods should be Show-address( )
retested in the context
of a subclass
• Example: if we change a
method show-address() Faculty Students Staff
Derived
to retest show-
address() and other
dependent methods
inside all subclasses that
inherit it. UnderGrad PostGrad Research
70
Deep Inheritance Hierarchy
• A subclass at the bottom of a deep
hierarchy:
– May have only one or two lines of code.
– But may inherit hundreds of features.
• This situation creates fault hazards:
– Similar to unrestricted access to
global data in procedural programs.
• Inheritance weakens encapsulation.
71
Deep Inheritance
Hierarchy cont...
• A deep and wide inheritance hierarchy can
defy comprehension:
– Lead to bugs and reduce testability.
– Incorrect initialization and forgotten
methods can result.
– Class flattening may increase
understandibility.
• Multiple Inheritance:
– Increases number of contexts to test.
72
Abstract and Generic
Classes
• Unique to OO programming:
– Provide important support for reuse.
• Must be extended and instantiated to be
tested.
• May never be considered fully tested:
– Since need retesting when new
subclasses are created.
73
Testing an Abstract Class
• Not possible to LibraryMember Abstract Class
directly test it.
• Can only be
indirectly tested
through classes Faculty Students Staff
Derived
derived from it. Classes
• So can never be
considered as fully
tested.
UnderGrad PostGrad Research
74
Polymorphism
• Each possible binding of a
polymorphic component requires
separate testing:
– Often difficult to find all bindings
that may occur.
– Increases the chances of bugs .
– An obstacle to reaching coverage
goals.
75
Polymorphism
cont…
• Polymorphism complicates
integration planning:
– Many server classes may need to
be integrated before a client
class can be tested.
C S1 S3
S2
76
Dynamic Binding
• Dynamic binding implies:
– The code that implements a given
function is unknown until run time.
– Static analysis cannot be used to
identify the precise dependencies
in a program.
• It becomes difficult to identify all
possible bindings and test them.
77
Dynamic Binding: the combinatorial
explosion problem
Class member{
...
abstract boolean validatePayment(Account a, int amt, Card c) ;
…
}
GoldMember
SilverMember IndianAccount VISACard
OrdMember UKAccount AmExpCard
EUAccount DebitCard
JPAccount
OtherAccount
78
How many test cases for pair wise
testing?
m11
m1
m15
m
m51
m5
m55 79
State-Based Testing
• The concept of control flow of a
conventional program :
– Does not map readily to an OO
program.
• In a state model:
– We specify how the object's state
would change under certain
conditions.
80
State-Based Testing
• Flow of control in OO programs:
– Message passing from one
object to another
• Causes the receiving object to
perform some operation,
– can lead to an alteration of its
state.
81
State-Based Testing
cont...
Accepted
Rejected Order
Order
[some items not available] [some items available]
Processed Processed/deliver
83
Example: State chart diagram for an order object
State-Based Integration Testing
cont...
• Test cases can be derived from the
state machine model of a class:
– Methods result in state transitions.
– Test cases are designed to
exercise each transition at a state.
• However, the transitions are tied to
user-selectable activation sequences:
– Use Cases
84
Difficulty With State
Based Testing
• The locus of state control is distributed over
an entire OO application.
– Cooperative control makes it difficult to
achieve system state and transition
coverage.
• A global state model becomes too complex for
practical systems.
– Rarely constructed by developers.
– A global state model is needed to show how
classes interact.
85
Test Coverage
• Test coverage analysis:
– Helps determine the “thoroughness” of
testing achieved.
• Several coverage analysis criteria for
traditional programs have been proposed:
– What is a coverage criterion?
• Tests that are adequate w.r.t a criterion:
– Cover all elements of the domain
determined by that criterion.
86
Test Coverage
Criterion cont...
• But, what are the elements that
characterize an object-oriented program?
– Certainly different from procedural
programs.
– For example: Statement coverage is not
appropriate due to inheritance and
polymorphism.
• Appropriate test coverage criteria are
needed.
87
Test Process Strategy
• Object-oriented development tends
toward:
– Shorter methods.
– Complexity shifts from testing methods
to class relations
– In this context model based testing
(also called grey box testing) of object-
oriented programs assumes importance.
88
Integration Testing
• OO programs do not have a hierarchical
control structure:
– So conventional top-down and bottom-up
integration tests have little meaning
• Integration applied three different incremental
strategies:
– Thread-based testing: integrates classes required to
respond to one input or event
– Use-based testing: integrates classes required by one
use case
– Cluster testing: integrates classes
required to demonstrate
one collaboration
89