01-Introduction To Software Testing - 2
01-Introduction To Software Testing - 2
22
Advanced Software Testing
Module 1:
Introduction to Software Testing
Winter 2008
Recall:
SQC is about controlling the quality of SE products.
Includes (1) inspections, and (2) testing.
Configuration
Verification
Management
Under Test
Under Test
Test suite
exercises is revised by
* * 1…n
Test case Unit Correction
* *
*
Test stub
finds
repairs
* Test driver
* *
Failure * * Fault * * Error
is caused by is caused by
Dijkstra, 1972:
“Program testing can be used to show
the presence of bugs, but never to
show their absence”
Thus:
No absolute certainty can be gained
from testing
Testing should be integrated with
other verification activities, e.g., code
reviews and inspections
Main goal of testing: demonstrate the
software can be depended upon, i.e.,
sufficient dependability
We can only gain sufficient confidence
in the System Under Test (SUT), but
not
Dr. V. Garousi, full
SENG confidence!
607.22 – W 2008 42
Goals and Limitations of Testing (cont.)
[Test Result!=Oracle]
Correctness, Reliability:
The system should let traffic pass according to the correct pattern and central
scheduling on a continuous basis.
Robustness:
The system should provide degraded functionality in the presence of abnormalities.
Safety:
It should never signal conflicting greens.
An example degraded function: the line to central controlling is cut-off and a default
pattern is then used by local controller.
Dr. V. Garousi, SENG 607.22 – W 2008 52
SW Dependability Needs Vary
Safety-critical applications
Flight control systems have strict safety requirements
Telecommunication systems have strict robustness
requirements
Mass-market products
Dependability is often less important than time to
market ($)
Exhaustive Testing
Test Coverage and Types of Testing
Black vs. White Box Testing
Complete Coverage
Software Representation
(e.g., model, code) Associated Criteria
Test cases must cover
all the … in the model
Test Cases
System
Specification
Implementation
Exhaustive Testing
Test Coverage
Black vs. White Box Testing
Complete Coverage
In White-Box testing
In Black-Box testing
An example first:
if x > y then
Max := x;
else
Max := x ; // fault! Should have been y
end if;
Let’s see what test cases can “cover” the above program:
Test set (suite) {(x=3, y=2), ( x=2, y=3)} can detect the error,
and has more “coverage”
Test set (suite) {(x=3, y=2), (x=4, y=3), (x=5, y=1)} is larger but
cannot detect it
Test coverage criteria group input domain elements into
(equivalence) classes (control flow paths here)
Complete coverage attempts to run test cases from each
and every of those classes
Dr. V. Garousi, SENG 607.22 – W 2008 62
Complete Coverage: In Black-Box testing
Formal definitions
Adequacy Criterion
Ideal Test Set
Test Consistency and Completeness
Empirical Testing Principle
Formal definitions
Adequacy Criterion
Ideal Test Set
Test Consistency and Completeness
Empirical Testing Principle
Let P be a program
Let D and R denote its input domain and range,
i.e.:
P is a function: D→R
Let OR denote the expected output values
(ORacle)
P is said to be correct for d D if P(d) satisfies
OR; if not, we have a failure
A test case is an element d of D and the
expected value of P in OR given d
A test set (a.k.a. suite) T is a finite set of test
cases
Dr. V. Garousi, SENG 607.22 – W 2008 67
Theoretical Foundations of Testing
Formal definitions
Adequacy Criterion
Ideal Test Set
Test Consistency and Completeness
Empirical Testing Principle
Formal definitions
Adequacy Criterion
Ideal Test Set
Test Consistency and Completeness
Empirical Testing Principle
Formal definitions
Adequacy Criterion
Ideal Test Set
Test Consistency and Completeness
Empirical Testing Principle
Formal definitions
Adequacy Criterion
Ideal Test Set
Test Consistency and Completeness
Empirical Testing Principle
unit
Unit
testing
.
.
Unit code
Unit
Tested
Unit code
testing SYSTEM
IN USE!
Pfleeger, 1998
Dr. V. Garousi, SENG 607.22 – W 2008 81
Testing Activities at different Stages
Testing Activities
Visibility Visibility of
No visibility of code
of code details integration structures
Some
Complex stubbing No drivers/stubs
stubbing
Unit testing
Integration testing
System testing
Acceptance Testing
Test
A unit is the smallest testable part of an application.
In procedural programming, a unit may be an individual
program, function, procedure, etc.
In object-oriented programming, the smallest unit is a
method; which may belong to a base/super class,
abstract class or derived/child class.
Unit to
be tested
local data
structures
boundary
conditions
error handling paths
interface
…
test cases
Dr. V. Garousi, SENG 607.22 – W 2008 85
Unit Testing
Need an effective adequacy criterion.
Work with source-code analysis tools
appropriate for the criterion and development
environment.
May need to develop stubs and domain-
specific automation tools.
Although a critical testing phase, it is often
performed poorly in industry…
Unit testing
Integration testing
System testing
Acceptance Testing
Test
Test cases have to be planned, documented, and
reviewed.
Performed in a relatively small time-frame
Dependency
B F G
Or
D E
B F G
Under Test
Dr. V. Garousi, SENG 607.22 – W 2008 91
Bottom-Up Integration Testing
A
Dependency
B F G
Reminder:
A cluster Test Stub Test Driver
Depends Depends
Component a Component b Component j Component k
Incremental – Advantages:
Focus is on each module better testing?
Easy to locate errors, fault localization, etc.
Incremental – Disadvantages:
Need to develop special code (stubs and/or drivers)
Unit testing
Integration testing
System testing
Acceptance Testing
Test
Unit testing
Integration testing
System testing
Acceptance Testing
System testing
The software is compared with the requirements
specifications (verification)
Usually performed by the developers, who know the
system
Acceptance testing
The software is compared with the end-user
requirements (validation)
Usually performed by the customer (buyer), who knows
the environment where the system is to be used
Sometime distinguished between - and -testing for
general purpose products
Alpha testing is a simulated or actual operational testing by
potential users/customers or an independent test team at the
developers' site.
Beta testing comes after alpha testing. Versions of the
Dr. V. Garousi, SENG 607.22 – W 2008 98
More on Testing vs. Verification and
Validation
Verification ensures that the product satisfies or matches
the original design (low-level checking) — i.e., you built
the product right. This is done through (white-box) testing.
Validation checks that the product design satisfies or fits
the intended usage (high-level checking) — i.e., you built
the right product. This is done through (black-box) testing.
Two fundamental approaches to verification:
Dynamic verification (also known as Testing)
Static verification (also known as Analysis, e.g.,
inspections)