Professional Documents
Culture Documents
Software Testing What & Why
Software Testing What & Why
Testing
What &
Why
Introduction
Software Testing
Books:
1.Software Testing, By: Yogesh Singh,
Cambridge University Press
2. Software testing: A Craftsman Approach
By: Paul C. Jorgensen, CRC Press
3. Software testing in the real world
By: Edward Kit, Pearson Education
4. Software testing: Principles and practices
By:Srinivasan Desikan and Gopalaswamy Ramesh,
Pearson Education
Software Testing
Overview
In a typical testing project, someone gives you a program and
asks you to test it.
The program may (or may not) come with a specification and
documentation.
Documents vary in accuracy and completeness.
You create tests, run them, and report the progress and
results of your work.
New versions of the program come to you. You might
reuse some old tests, check whether bugs have been
fixed, and (or) try new tests.
Eventually, the product is either cancelled or put into production.
3
Software Testing
What is testing?
A technical investigation of the product under test conducted to
provide stakeholders with quality-related information.
Defining Testing
A technical
means including experimentation, logic, mathematics, models,
tools (testing-support programs), and tools (measuring instruments,
event generators, etc.)
investigation
An organized and thorough search for information.
This is an active process of inquiry. We ask hard questions
(run hard test cases) and look carefully at the results.
Software Testing
of the product under test
The product includes the data, the documentation, the
hardware, whatever the customer gets. If it doesnt all work
together, it doesnt work.
stakeholders
Information Objectives
Find important bugs, to get them fixed
Assess the quality of the product
Help managers make release decisions
Block premature product releases
Help predict and control costs of product support
Check interoperability with other products
Find safe scenarios for use of the product
Assess conformance to specifications
Information Objectives
methods,
measurements, tools and equipments are integrated to test the
software product.
1. The quality of the test process determines the success of
test effort:
Quality and effectiveness of software testing are determined
primarily by the quality of test processes used.
2. Prevent defect migration by using early life cycle testing
techniques:
More than half the errors are usually introduced at the
requirement phase.
Effective test program prevents the migration of errors from
any development phase to any subsequent phase.
8
6.
Objective of testing
To show that a product do what it shouldt
do.
To show that a product doest do what it
should
11
of
university syllabus
Training in the industry is there but not properly defined
Published papers giving state of art methods are unproven in
the field (many well proven methods are unused in industry)
and omit real world dimension like return on investment.
12
History Aspects
Early days:
Testing was debugging (fix the bugs), performed by
developers.
Few dedicated resources for testing that too were very late in
the development process.
1957:
Testing distinguished from debugging.
Testing was still an after development activity.
1970:
Software engineering term used more often.
1972:
First formal conference on testing was held at the University
of North California.
13
History Aspects
1979:
Myers defined testing as The process of executing a
program with the intent of finding errors.
BUT IN THE REAL WORLD OF INDUSTRY: Testing got
dumped when the schedules and the budget becomes tight.
Testing too late to be done properly
1980:
Quality was buzzword
Various groups formed some standards like:
IEEE (Institute of Electrical and Electronics engineers)
ANSI (American National Standards Institute)
ISO (International Standards Organization)
1990:
Testing tools came.
14
15
Software Testing
Establishing a practical perspective
Ultimate goal of testing: Quality Maintenance and Satisfaction
of customers.
What and why?
Mistake: A human action that produces incorrect result.
(Mistake produces fault or bug)
Fault: An incorrect step, process or data definition in a computer
program. The outgrowth of a mistake. (Potentially leads to
a failure)
Failure: An incorrect result. The result of the fault.
Error: The amount by which the result is incorrect
16
Software Testing
Where are errors?
Errors are concentrated in earlier stages of development
process. (Fig. 1.1)
17
Historical definitions of
The cost of errors: All are
costly.
testing
Historical definitions of
testing
5. The measurement of software quality (hetzel, 1983)
6. The process of evaluating a program or system.
7. Verifying that a system satisfies its specified requirement or
identifying difference between expected and actual results.
8. Confirming that a program performs its intended function
correctly.
19
20
Status of Software
Engineering
Therequirements
specificationwas
definedlikethis
Thedevelopers
understooditin
thatway
Thisishowthe
problemwas
solvedbefore.
Thisishowtheprogramis
Thatistheprogramafter describedbymarketing
department
debugging
Thisishowthe
problemis
solvednow
This,infact,iswhatthe
customerwanted
21
22
23
Some Software
failures
Y2K problem:
It was simply the ignorance about the
adequacy or otherwise of using only
last two digits of the year.
The 4 digit date format, like 1964,
was shortened to 2 digit format, like
64.
24
25
Experience of Windows XP
Released on October 25,2001
Same day company posted 18 megabytes of
patches on its website for bug fixes, compatibility
updates and enhancements.
27
EXAMPLE
28
29
EXAMPLE
.
Inputs
Size
Set of integers
Expected
output
Observed
output
Match ?
6,9,2,16,19
Yes
96,11,32,9,39,99,91
Yes
31,36,42,16,65,76,81
16
16
Yes
28,21,36,31,30,38
21
21
Yes
106,109,88,111,114,116
88
88
Yes
61,69,99,31,21,69
21
21
Yes
6,2,9,5
Yes
99,21,7,49
Yes
30
Situations
We again consider the minimum() program and concentrate on some
typical and critical situations :
(i)
A very short list (of inputs) with the size of 1,2 or 3
elements.
(ii)
(iii)
(iv)
(v)
Cont.
31
Situations
(vi)
(vii)
32
Situations
In the previous table, we have selected elements in every list to
cover essentially the same situation :
A list of moderate size.
Containing all positive integers.
Minimum is somewhere in the middle.
33
Size
Set of Integers
a
b
c
d
e
f
1
2
2
3
3
3
Case 3
A list where minimum
element is first or last
element
10,23,34,81,97
Case 4
A list where minimum
element is negative
a
b
Case 1
A very short list with
size 1,2 or 3
Case 2
An empty list i.e. of
size 0
90
12,10
10,12
12,14,36
36,14,12
14,12,36
o/p
90
10
10
12
12
12
2147483647
2147483647
2147483647
14
14
12
No
No
No
No
No
Yes
Error
message
2147483647
No
10
23
No
97,81,34,23,10
10
23
No
10,-2,5,23
-2
No
5,-25,20,36
-25
20
No
----
Cont.
34
Inputs
Size
Set of Integers
Expected
o/p
Observed o/p
Match
?
Case 5
A list where all
elements are
negative
-23,-31,-45,-56,-78
-78
31
No
-6,-203,-56,-78,-2
-203
56
No
Case 6
A list where some
elements are real
numbers
12,34.56,6.9,62.14,19
5.4
Case 7
A list where some
elements are
characters
Case 8
A list with duplicate
elements
6.9
No
No
2,3,5,6,9
23,2 I,26,6,9
1I
2,3,4,9,6,5,11,12,14,21,
22
3,4,6,9,6
No
13,6,6,9,15
Yes
530,4294967297,23,
46,59
23
No
Case 9
a
Value greater than
maximum permissible
limit of an integer
No
No
35
While handling the minimum, the base value of the index and / or end value
of the index of the usable array has not been handled properly.
See line no. 25 & 26
Case 2
An empty list i.e. of
size 0
Case 3
A list where minimum
element is the first or
last element
Case 4
A list where minimum
element is negative
Case 5
A list where all
elements are negative
Cont.
36
Case 6
Some elements are
real numbers
Case 7
Some elements are
alphabetic characters
Case 8
A case with duplicate
elements
(a)
(b)
Case 9
A list with one value
greater than maximum
permissible limit of an
integer
Same as case 1
We are getting correct results because minimum value is in the
middle of the list and all values are positive.
37
Cases
Remarks
1 (a)
1 (b)
1 (c)
2147483647
2147483647
2147483647
The program has ignored first & last values of the list. This is the maximum
value of a 32 bit integer to which variable minimum is initialized.
1 (d)
1 (e)
14
14
The program has ignored first and last value of the list. Middle value is 14.
1 (f)
12
Ignored first & last value. Fortunately, middle value is minimum & thus the
result is correct.
2 (a)
2147483647
Same as 1 (a)
3 (a)
3 (b)
23
23
Ignored first & last value. 23 is the minimum value in the remaining lsit.
4 (a)
4 (b)
2
20
Ignored first & last value. It has also converted negative integer(s) to positive
integer(s).
Cont.
38
Cases
Remarks
5 (a)
5 (b)
31
56
Same as case 4
6 (a)
6 (b)
34
858993460
After getting . of 34.56, program was terminated & 34 was displayed.12 was
ignored due to first value:
For 6(b): Garbage value
7 (a)
7 (b)
2
2147483647
8 (a)
8 (b)
4
6
Same as case 3
Fortunately result is correct. Although, first & last value are ignored.
9 (a)
The program displays this value due to the overflow of the 32 bit signed integer
data type used in the program
39
1.
i=1;
while (i<No-1)
i=0;
while (i<=No-1)
40
41
42
Inputs
Size
Set of Integers
Observed o/p
90
10
10
12
12
12
90
10
10
12
12
12
Error
message
Error message
Match ?
a
b
c
d
e
f
1
2
2
3
3
3
Case 3
A list where minimum
element is first or last
element
10,23,34,81,97
10
10
Yes
97,81,34,23,10
10
10
Yes
Case 4
A list where minimum
element is negative
10,-2,5,23
-2
-2
Yes
5,-25,20,36
-25
-25
Yes
Case 1
A very short list with
size 1,2 or 3
Case 2
An empty list i.e. of
size 0
90
12,10
10,12
12,14,36
36,14,12
14,12,36
Expected
o/p
----
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Cont.
43
Inputs
Size
Set of Integers
Expected
o/p
Observed o/p
Match
?
Case 5
A list where all
elements are
negative
-23,-31,-45,-56,-78
-78
-78
Yes
-6,-203,-56,-78,-2
-203
-203
Yes
Case 6
A list where some
elements are real
numbers
12,34.56,6.9,62.14,19
5.4
Case 7
A list where some
elements are
characters
Case 8
A list with duplicate
elements
6.9
12
No
2,3,5,6,9
838993460 (Program
does not take any array
value)
No
23,2 I,26,6,9
No
1I
2,3,4,9,6,5,11,12,14,21,
22
3,4,6,9,6
Yes
13,6,6,9,15
Yes
530,4294967297,23,
46,59
23
No
Case 9
a
Value greater than
maximum permissible
limit of an integer
No
44
Case 6 & case 7 are failed due to scanf() function parsing problem
Do not use scanf()
If use scanf(), display a warning message for the user before
using scanf()
45
46
48
Role of Persons
Sr.
No.
1
2
Persons
Roles
Customer
Project Manager
Software
developer (s)
Testing
Co-ordinator (s)
Invalid inputs
53
Line Numbers
Symbol for
representation
2,3,4
6,7,8
end
54
Sequences
B
F
A
D
C
G
X
EXIT
H
I
< 20 times
through the
loop
Sequences
B
F
A
D
C
G
X
EXIT
H
I
< 20 times
through the
loop
Sequences
B
F
A
D
C
G
X
EXIT
H
I
< 20 times
through the
loop
Sequences
B
F
D
G
X
E
EXIT
H
I
< 20 times
through the
loop
Third: ACDGX--EXIT
60
Sequences
B
F
A
D
C
E
EXIT
H
I
< 20 times
through the
loop
Fourth: ACEHX--EXIT
61
Sequences
B
A
F
D
C
E
EXIT
H
I
< 20 times
through the
loop
Sequences
B
F
A
D
C
E
G
H
I
EXIT
< 20 times
through the
loop
Sequences
B
F
A
D
C
E
G
H
I
EXIT
< 20 times
through the
loop
64
Sequences
Analyzing Myers example
There are 51 + 52 + ... + 519 + 520 = 1014 =
100 trillion paths through the program.
It would take only a billion years to test
every path (if one could write, execute and
verify a test case every five minutes).
65
66
Input (j)
Expected Result
Actual Result
42
40000
-64000
-2
-2
Expected Result
Actual Result
30,000
29,999
-29,999
-1
-30,000
Four of the these possible 65,536 input values will find this
defect. What is the chance that we will choose all four? What
is the chance we will choose one of the four?
69
Limitation of Testing
Complete Testing Is Impossible
70
Complete testing?
What do we mean by "complete testing"?
Complete "coverage": Tested every line / branch / basis path?
Testers not finding new bugs?
Test plan complete?
After all, if there are more bugs, you can find them if you do
more testing. So testing couldn't yet be "complete."
71
72
74
A high bug count could mean that testing was thorough and
very few bugs remain. Or, it could mean that the software
simply has lots of bugs and, even though many have been
exposed, lots of them remain. These counts may be illusive and
do not help us to measure the progress of testing.
When to release the software is a sensitive decision & should be
based on the status of testing. Although in the absence of testing
standards, economics, time to market and gut feeling
have become important issues over technical considerations for
the release of any software. Many reliability models are
available with many limitations and are not universally
acceptable.
76
What is Software?
Computer programs and associated documentation
78
What is software?
Programs
Documentatio
n
Operating
Procedures
Software=Program+Documentation+Operating Procedures
Components of software
79
ContextDiagram
Data Flow
Diagrams
Design
Documentation
Manuals
Flow Charts
Entity-Relationship
Diagram
Source Code Listings
Implementation
Testing
Cross-Reference
Listing
Test Data
Test Results
80
Beginners Guide
Tutorial
Reference Guide
Operating
Procedures
Installation Guide
Operational
Manuals
System
Administration Guide
81
Software Testing
Error, Mistake, Bug, Fault and Failure
People
make
errors.
good
Sometimes,
there
coding,
we
call
these
mistakes bugs.
82
Software Testing
A fault is the representation of an error, where representation
is the mode of expression, such as narrative text, data flow
diagrams, ER diagrams, source code etc. Defect is a good
synonym for fault.
Fault is of two types:(a)Fault of commission
(b)Fault of omission
83
Software Testing
FAULT OF COMMISSION:- It occurs when we enter
something into a representation that is incorrect.
FAULT OF OMISSION:- It occurs when we fail to enter correct
Information
Of these two types, faults of omission are more difficult to
detect and resolve.
84
Software Testing
A failure occurs when a fault executes. A particular fault may
cause different failures, depending on how it has been
exercised.
Correspond to fault of commission
Failure
Fault of omission are found by
careful reviews
85
Software Testing
INCIDENT:- When a failure occurs, it may or may not be
readily apparent to the user . An incident is the symptom
associated with a failure that alerts the user to the occurrence
of failure.
86
Erroneous State
(Error)
Errors
Errors
Stress
Stressor
or overload
overloaderrors
errors
Capacity
Capacityor
or boundary
boundary
errors
errors
Timing
Timingerrors
errors
Throughput
Throughputor
or
performance
performanceerrors
errors
87
Algorithmic Fault
Algorithmic
Algorithmic Faults
Faults
Missing
Missinginitialization
initialization
Branching
Branchingerrors
errors(too
(too
soon,
soon, too
toolate)
late)
Missing
Missingtest
testfor
for nil
nil
88
Mechanical Fault
Mechanical
Mechanical Faults
Faults
(very
(very hard
hard to
to find)
find)
Documentation
Documentation does
does
not
actual
not match
match
actual
conditions
conditions or
or operating
operating
procedures
procedures
89
90
Modular Redundancy?
Modular redundancy:
Expensive
91
Declaring a bug to be a
feature
Bad practice
92
Patching?
Patching
Slows down performance
93
Testing?
Testing
Testing is never good enough
94
Section-II
(After Execution)
Execution History:
Result:
If fails, any possible reason (Optional);
Expected Outputs:
Post conditions:
Written by:
Date:
The set of test cases is called a test suite. Hence any combination of
95
test cases may generate a test suite.
Software Testing
TEST CASE:-
Software Testing
97
Software Testing
INSIGHT FROM A VENN DIAGRAM
Testing is fundamentally concerned with behavior and
behavior is orthogonal to the structural view common to
software developers.
One of the continuing sources for difficulty for testers is
that the base documents are usually written by and for
developers, the emphasis is on structural, instead of
behavioral information.
So, we use venn diagram to clarify questions about testing.
98
Software Testing
Software Testing
What if certain specified behavior are not programmed? These
are faults of omission
What if certain Programmed behavior are not Specified? These
are faults of commission.
The intersection of S and P is the correct portion, that is,
behavior that are both specified and implemented and it is the
good view of testing.
100
Software Testing
Software Testing
Specified behaviors that are tested(regions 1 and 4)
Test cases that corresponds to unspecified behavior(regions3 and 7)
Programmed behaviors that are not tested(regions 2 and 6)
Programmed behavior that are tested(region 1and 3)
Test cases that corresponds to unprogrammed behavior(regions 4 and 7)
102
Software Testing
If certain test cases corresponds to unspecified behaviors, two
possibilities arise:
(a) Such a test case is unwanted
(b) Specification is deficient.
103
Software Testing
FUNCTIONAL TESTING
With functional approach to test case identification, the only
information used is the specification of software. Functional test case
have two advantages:
(1) They are independent of how the software is implemented, so if the
implementation changes, the test case are still useful.
(2) Test cases development can occur in parallel with the implementation,
thereby reducing overall project development interval.
104
Software Testing
Above figure shows the result of test cases identified by two functional
methods.
105
Software Testing
Method A identifies a larger set of test cases than does Method B.
The above is due to the fact that the functional methods are based
.
on the specified behavior, It is hard to imagine these methods
identifying behaviors that are not specified.
106
Software Testing
STRUCTURAL TESTING
Software Testing
Software Testing
Method A identifies a larger set of test cases than Method B.
For both methods, the set of test cases is completely contained
within the set of programmed behavior.
Because structural method are based on the program, it is hard
to imagine these methods identifying behaviors that are not
programmed.
It is easy to imagine, however, that a set of structural test cases
is relatively small with respect to the full set of programmed
behaviors.
109
Software Testing
THE FUNCTIONAL VERSUS STRUCTURAL
DEBATE
Software Testing
If all specified behaviors have not been
implemented, structural test case will never be able
to recognize this.
Conversely, if the program implements behavior that
have not been specified, this will never be revealed
by functional test cases.
Thus: Both approaches are needed; a judicious
combination will provide the confidence of the
functional testing and the measurement of structural
testing.
111
Fault Example
Mild
Misspelled word
Moderate
Annoying
Disturbing
Serious
Lose a transaction
Very Serious
Extreme
Intolerable
Database corruption
Catastrophic
System Shutdown
Infectious
112
Input/output Faults
Type
Input
Output
Instances
Correct input not accepted
Incorrect input accepted
Description wrong or missing
Parameters wrong or missing
Wrong format
Wrong result
Correct result at wrong time(too early , too
late)
Incomplete or missing results
Spelling/grammar
Cosmetic
Logic Faults
Missing case(s)
Duplicate case(s)
Extreme condition neglected
Misinterpretation
Missing Condition
Extraneous condition)s)
Test of wrong variable
Incorrect loop iteration
Wrong operator(e.g., <instead of<=)
Computational Faults
Incorrect algorithm
Missing Computation
Incorrect operand
Incorrect operation
Parenthesis error
Insufficient precision(round-off, truncation)
Wrong built-in function
Interface Faults
Incorrect interrupt handling
I/O timing
Call to wrong procedure
Call to nonexistent procedure
Parameter mismatch(type, number)
Incompatible types
Superfluous types
Data Faults
Incorrect initialization
Incorrect storage/access
Wrong flag/index/value
Incorrect packing/unpacking
Wrong variable used
Wrong data reference
Scaling or units error
Incorrect data dimension
Incorrect subscript
Incorrect type
Incorrect data scope
Sensor data out of limits
Off by one
Inconsistent data
Software Testing
Deliverables and Milestones
Different deliverables are generated during various phases of
software development. The examples are source code, software
requirement and specification (SRS) document, software design
document (SDD), installation guide, user reference manual etc.
Milestones are the events that are used to ascertain the status of the
project.
Example, finalization of SRS is a milestone. Completion of SDD is
another milestone.
The milestones are essential for monitoring and planning the
progress of the development.
118
Software Testing
Alpha, Beta and Acceptance Testing
The term Acceptance Testing is used when the software is developed
for a specific customer. A series of tests are conducted to enable the
customer to validate all requirements. These tests are conducted by
the end user / customer and may range from adhoc tests to well
planned systematic series of tests.
The terms alpha and beta testing are used when the software is
developed as a product for anonymous customers.
Alpha Tests are conducted at the developers site by some potential
customers. These tests are conducted in a controlled environment.
Alpha testing may be started when formal testing process is near
completion.
Beta Tests are conducted by the customers / end users at their sites.
Unlike alpha testing, developer is not present here. Beta testing is
conducted in a real environment that cannot be controlled by the
119
developer.
Software Testing
Quality and Reliability
Software reliability is one of the important factor of software quality.
Software reliability is defined as:
the probability of failure free operation for the specified time in a
specified environment
Software Quality measures how well software is designed (quality of
design), and how well the software conforms to that design (quality of
conformance).
Software Reliability is one of the part of software quality.
To produce good quality product, a software tester must verify and
validate throughout the software development process.
120
Software Testing
Testing, Quality Assurance and Quality Control
The purpose of testing is to find bugs and find them as early as
possible.
The purpose of quality assurance activities is to enforce standards
and techniques to improve the development process and prevent
bugs from ever occurring.
Quality assurance group monitors and guides throughput the
software development life cycle. Examples are reviews, audits, etc.
Quality control attempts to build a software and test it thoroughly. It
concentrates on specific products rather than processes as in the
case of quality assurance. This is a defect detection and correction
activity which is usually done after the completion of the software
development,. Example is software testing at various levels.
121
Software Testing
Static and Dynamic Testing
Static Testing refers to testing activities without executing the code.
All verification activities like inspections, walkthroughs, reviews etc
come under this category of testing.
Static Testing should be started at earlier phases of software
development and gives very good results at reasonable cost.
Dynamic Testing refers to execute the code and see how it performs
with specific inputs. All validation activities comes in this category
where execution of program is essential.
122
Software Testing
Testing and Debugging
The purpose of testing is to find faults and find them as early as
possible.
The process used to determine the cause of the fault and to remove it
is known as debugging.
123
Acceptance Testing
B
System testing
Detailed design
Implementation
125
126
2.
3.
127
4.
Audit level testing: It is a bare bones audit of plans,
procedures, and products for adequacy, correctness and
compliance to standards.
Use full testing for critical software or any s/w that will
have heavy and diverse usage by a large user
population.
Use partial testing for small, non-critical software
products with a small, captive user population.
128