0% found this document useful (0 votes)
32 views24 pages

Class 16

The document discusses different techniques for testing software programs such as inputting test data and observing outputs, identifying errors, faults and failures, verification versus validation, designing test cases and test suites, equivalence class partitioning and boundary value analysis.

Uploaded by

vedidom615
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views24 pages

Class 16

The document discusses different techniques for testing software programs such as inputting test data and observing outputs, identifying errors, faults and failures, verification versus validation, designing test cases and test suites, equivalence class partitioning and boundary value analysis.

Uploaded by

vedidom615
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

Testing and Debugging

1
How Do You Test a
Program?
● Input test data to the
program.
● Observe the output:
– Checkif the program
behaved as expected.

2
Error, Faults, and
Failures
● A fault is an incorrect state
entered during program
execution:
– A variable value is different from
what it should be.
– A fault may or may not not lead
to a failure.

3
Verification versus
Validation
● Verification is the process of
determining:
– Whether output of one phase of
development conforms to its previous
phase.

● Validation is the process of


determining:
– Whether a fully developed system
conforms to its SRS document. 4
Test cases and Test
suites
● Test a software using a set
of carefully designed test
cases:
– The set of all test cases is
called the test suite

5
Test cases and Test
suites
● A test case is a triplet [I,S,O]
– I is the data to be input to the
system,
– S is the state of the system at
which the data will be input,
– O is the expected output of the
system.

6
Design of Test Cases
● Exhaustive testing of any non-
trivial system is impractical:
– Input data domain is extremely large.

● Design an optimal test suite:


– Of reasonable size and
– Uncovers as many errors as
possible.

7
Design of Test Cases
● If test cases are selected randomly:
– Many test cases would not contribute to
the significance of the test suite,
– Would not detect errors not already being
detected by other test cases in the suite.
● Number of test cases in a randomly
selected test suite:
– Not an indication of effectiveness of
testing.
8
Design of Test Cases
● The code has a simple programming error:
● If (x>y) max = x;
else max = x;
● Test suite {(x=3,y=2);(x=2,y=3)} can
detect the error,
● A larger test suite {(x=3,y=2);(x=4,y=3);
(x=5,y=1)} does not detect the error.

9
Design of Test Cases
● There are essentially two
main approaches to design
test cases:
– Black-box approach
– White-box (or glass-box)
approach

10
Black-Box Testing
● Test cases are designed using only
functional specification of the
software:
– Without any knowledge of the
internal structure of the software.
● For this reason, black-box testing
is also known as functional
testing.
11
White-box Testing

● Designing white-box test cases:


– Requires knowledge about the
internal structure of software.
– White-box testing is also called
structural testing.

12
Black-Box Testing
● There are essentially two
main approaches to design
black box test cases:
– Equivalence class partitioning
– Boundary value analysis

13
Equivalence Class
Partitioning
● Input values to a program are
partitioned into equivalence
classes.
● Partitioning is done such that:
– Program behaves in similar ways
to every input value belonging to
an equivalence class.
14
Equivalence Class
Partitioning
● How do you determine the
equivalence classes?
– Examine the input data.
– Few general guidelines for
determining the equivalence
classes can be given

15
Equivalence Class
Partitioning
● If the input data to the program is
specified by a range of values:
– e.g. numbers between 1 to 5000.
– One valid and two invalid equivalence
classes are defined.

1 5000

16
Example
● A program reads an input value
in the range of 1 and 5000:
– Computes the square root of the
input number

SQR
T

17
Example (cont.)
● There are three equivalence classes:
– The set of negative integers,

– Set of integers in the range of 1 and


5000,
– Integers larger than 5000.

1 5000

18
Example (cont.)

● The test suite must include:


– Representatives from each of the
three equivalence classes:
– A possible test suite can be:
{-5,500,6000}.

1 5000

19
Equivalence Class Partitioning
● If input is an enumerated set of
values:
– e.g. {a,b,c}
– One equivalence class for valid input
values.
– Another equivalence class for invalid input
values should be defined.

20
Boundary Value Analysis
● Some typical programming errors occur:
– At boundaries of equivalence classes

– Might be purely due to psychological


factors.
● Programmers often fail to see:
– Special processing required at the
boundaries of equivalence classes.

21
Boundary Value Analysis
● Programmers may improperly
use < instead of <=
● Boundary value analysis:
– Select test cases at the
boundaries of different
equivalence classes.

22
Example
● For a function that computes
the square root of an integer in
the range of 1 and 5000:
– Test cases must include the
values: {0,1,5000,5001}.

1 5000

23
Thanks

24

You might also like