Jimma Institute of Technology
Faculty of Computing and Informatics
Software Testing and Quality Assurance (SEng4051)
1
Chapter Four
Software Testing Technique
Software Testing
3
Black Box Testing
Focuses on the functional requirements of
the software Also called behavioral testing
Does not need any knowledge of internal
design or code
It enables the software engineer to derive
sets of input conditions that will fully exercise
all functional requirements for a program.
Black-box testing is not an alternative to
white-box techniques but it is
complementary approach.
4
Cont..
5
Cont..
Tester is needed to be thorough with the requirement
specifications of the system
User should know how the system should behave in
response to the particular action
Black-box testing attempts to find errors in the
following categories:
Incorrect or missing functions, Interface errors,
Errors in data structures or external data base access.
Behavior or performance errors,
Initialization and termination errors
6
Commonly used Black Box methods
1. Equivalence partitioning
2. Boundary-value analysis
3. Error guessing
7
Equivalence partitioning
Equivalence testing is a black-box testing
method that divides the space of all possible
inputs into equivalence groups such that the
program “behaves the same” on each group
Two steps:
1. partitioning the values of input parameters into
equivalence groups
2. choosing the test input values
8
Equivalence partitioning
1.‘‘If an input condition for the software-under-test is
specified as a range of values, select one valid
equivalence class that covers the allowed range and two
invalid equivalence classes, one outside each end of the
range.’’
For example, suppose the specification for a module says that
an input, the length of a Wire in millimetres, lies in the range 1–
499; then select
One valid equivalence class that includes all values from 1
to 499.
Two invalid classes
That consists of all values less than 1, and
That consists of all values greater than 499.
9
Cont.…
2. If an input condition requires a specific
value, one valid and two invalid equivalence
classes are defined
– Input value: 250 Eq classes: {250}, {x <
250}, {x > 250}
10
Cont..
3. ‘‘If an input condition for the software-under-
test is specified as a set of valid input values, then
select one valid equivalence class that contains all
the members of the set and one invalid
equivalence class for any value outside the set.’’
For example, if the specification for a paint module
states that the colours RED, BLUE, GREEN and YELLOW
are allowed as inputs, then select
One valid equivalence class that includes the set
RED, BLUE, GREEN andYELLOW, and
One invalid equivalence class for all other inputs.
11
Cont.…
4. ‘‘If an input condition for the software-under-
test is specified as a “must be” condition, select
one valid equivalence class to represent the “must
be” condition and one invalid class that does not
include the “must be” condition.’’
For example, if the specification for a module states
that the first character of a part identifier must be a
letter, then select
o One valid equivalence class where the first character
is a letter and
o One invalid class where the first character is not a
letter.
12
Boundary Value Analysis(BVA)
A greater number of errors occur at the
boundaries of the input domain rather than in the
"center”
The test cases developed based on equivalence
class partitioning can be strengthened by use of a
technique called boundary value analysis. Many
defects occur directly on, above and below,
the edges of equivalence classes.
13
Cont..
1. If an input condition for the software-under-
test is specified as a range of values, develop
valid test cases for the ends of the range, and
invalid test cases for possibilities just above and
below the ends of the range.
For example if a specification states that an input
value for a module must lie in the range between -1.0
and +1.0,
Valid tests that include values -1.0, +1.0 for ends
of the range as well as
Invalid test cases for values just above and below
the ends - 1.1, +1.1, should be included.
14
Cont.….
2. If an input condition for the software-under-test
is specified as a number of values, develop valid
test cases for the minimum and maximum numbers
as well as invalid test cases that include one lesser
than minimum and one greater than the maximum
For example, for the real-estate module that specified
a house can have one to four owners,
Valid Tests that includes tests for minimum and
maximum values 1, 4 owners
Invalid tests that include one lesser than minimum
and one greater than maximum 0, 5 are developed.
15
Cont..
3. If the input or output of the software-under-
test is an ordered set, such as a table or a linear
list, develop tests that focus on the first and last
elements of the set
16
BVA-An Illustration
Write Test Cases using BVA for a requirement that is
stated as follows:
“In the examination grading system, if the student scores
0 to less than 40 then assign E Grade, if the student
scores between 40 to 49 then assign D Grade, if the
student scores between 50 to 69 then assign C Grade, if
the student scores between 70 to 84 then assign B
Grade, and if the student scores 85 to 100 then assign A
Grade.”
17
BVA-An Illustration
In the above problem definition, after analysis, we
identify following Boundary Values:
0 to 39 -E
40 to 49-D
50 to 69-C
70 to 84-B
85 to 100-A
18
BVA-An Illustration
Based on BVA, we identify following input values to test each
boundary:
For Boundary Values in range 0 to 39:
For 0 to 39 boundary values, Minimum Value= 0, Maximum
Value = 39, Precision is 1.
Thus, input values for testing for this boundary values are:
(Minimum Value-precision)= -1 Minimum Value= 0
(Minimum Value+ precision)= 1 (Maximum Value- precision)=
38
Maximum Value= 39 (Maximum Value + precision)= 40
Thus, input values for Boundary Values 0 and 39 are: -1, 0, 1,
38, 39, 40
19
BVA-An Illustration
On the similar lines of analysis, we arrive at following
input values for other Boundary values:
For 40 to 49, we have 39, 40, 41, 48, 49, 50
For 50 to 69, we have 49, 50, 51, 68, 69, 70
For 70 to 84, we have 69, 70, 71, 83, 84, 85
For 85 to 100, we have 84, 85, 86, 99, 100,
101
20
Error guessing
Error guessing is a technique in which there is no specific method
for identifying the error.
It is based on the experience of the test analyst, where the tester
uses the experience to guess the problematic areas of the software.
It is a type of black box testing technique which does not have any
defined structure to find the error
The main purpose of this technique is to identify common errors
• Enter blank space into the text fields.
• Null pointer exception.
• Enter invalid parameters.
• Divide by zero.
• Use maximum limit of files to be uploaded.
• Check buttons without entering values
21
White-box testing Technique
White-box testing (also called clear box
testing, glass box testing, transparent
box testing, or structural testing)
It is a method of testing software that
tests internal structures or workings of
an application [the tester has access to
the internal data structures and
algorithms including the code that
implement these.]
22
Cont..
White Box testing is based on the inner
workings of an application and revolves
around internal testing.
One of the basic goal of white box testing
is to verify a working flow for an application.
White box testing methods are especially
useful for revealing design and code-based
control, logic and sequence defects,
initialization defects, and data flow defects
23
Cont…
It examines source code and analyse what
is present in the code.
The following are some important
techniques of white-box testing:
A. Structural Testing
B. Basis Path Testing
C. Logic Based Testing
24
A. Structural Testing
It is a broaden testing coverage and
improve quality of white-box testing.
The following are some important types of
structural testing:
1. Statement coverage testing
2. Branch coverage testing Control Flow Testing
3. Condition coverage testing
4. Path coverage testing
5. Data flow based testing
25
Control Flow Testing
A white box testing technique to find bug is
control flow testing.
Control flow testing applies to almost all
software and is effective for most software.
It is a structural testing strategy that uses the
program’s control flow as a model control flow
testing favour more but simpler paths over
complicated but fewer paths. Control flow
testing is more effective for unstructured code
rather than structured code.
26
1. Statement Coverage Testing
Statement coverage aim:
design test cases so that every statement in a program is
executed at least once.
The principal idea:
unless a statement is executed, we have no way of
knowing if an error exists in that statement
Statement coverage = No of statements Executed/Total
no of statements in the source code * 100
Criterion:
Executing some statement once and observing that a
statement behaves properly for one input value:
no guarantee that it will behave correctly for all input27
values.
Source Code Structure
Scenario 1:
input (int a, int b) If a = 5, b = 4
print (int a, int b) {
{ int sum = a+b;
sum = a+b if (sum>0)
print ("This is a positive result")
If (sum>0) else
{ print ("This is negative result")
}
Print (This is positive resu SC = 5/7*100 = 500/7 = 71%
lt) } print (int a, int b) {
int sum = a+b;
else { if (sum>0)
print ("This is a positive result")
Print (This is negative res else
ult) } print ("This is negative result")
}
} SC = 6/7*100 = 600/7 = 85%
28
2. Branch coverage testing
Test cases are designed such that:
– different branch conditions is given true
and false values in turn.
Branch testing guarantees
statement coverage:
– a stronger testing compared to the
statement coverage-based testing.
29
3. Condition coverage testing
Test cases are designed such that:
– each component of a composite conditional
expression given both true and false values.
Example
– Consider the conditional expression
((c1.and.c2).or.c3):
– Each of c1, c2, and c3 are exercised at least
once i.e. given true and false values.
30
4. Path coverage testing
In path coverage, we write test cases to
ensure that each and every path has been
traversed at least once.
One way to better understand path
coverage:
– Draw a flow graph to indicate corresponding
logic in the program.
– Calculate individual paths in the flow graph.
– Run the program in all possible ways to cover
every statement.
31
Home practice.…
How to calculate Statement Coverage,
Branch Coverage & Path Coverage?
Draw the flow in the following way:
– Nodes represent entries , exists,
decisions, and each statement of code.
– Edges represent non-branching and links
between nodes
32
Example
1. Read P,Q
2. If P+Q>100 then
3. Print “Large”
4. End if
5. If P>50 then
6. Print “P Large”
7. End if
Calculate Statement Coverage, branch
coverage and path coverage
33
Cont..
34
Solution1
Statement Coverage (SC):
To calculate Statement Coverage, find
out the shortest number of paths
following which all the nodes will be
covered. Here by traversing through path
1A-2C-3D-E-4G-5H all the nodes are
covered. So by traveling through only one
path all the nodes 12345 are covered, so
the Statement coverage in this case is 1.
35
Branch Coverage (BC):
To calculate Branch Coverage, find out the
minimum number of paths which will ensure
covering of all the edges. In this case there is no
single path which will ensure coverage of all the
edges at one go. By following paths 1A-2C- 3D-
E-4G-5H, maximum numbers of edges (A, C, D,
E, G and H) are covered but edges B and F are
left. To covers these edges we follow 1A-2B-E-4F.
By the combining the above two paths we can
ensure of traveling through all the paths. Hence
Branch Coverage is 2. The aim is to cover all
possible true/false decisions.
36
Path Coverage (PC):
Path Coverage ensures covering of all the paths
from start to end. Every distinct path through the
code is executed atleast once.
All possible paths are-
1A-2B-E-4F
1A-2B-E-4G-5H
1A-2C-3D-E-4G-5H
1A-2C-3D-E-4F
So path coverage is 4.
Thus for the above example SC=1, BC=2 and
PC=4
37
Solution2
First, draw a flowchart graph.
Then evaluate Statement Coverage,
branch coverage and path coverage
– Statement coverage = 1 (1-2-3-4-5-6-7)
– Branch coverage = 2(1-2-4-5-7 , 1-2-3-
4-5-6-7)
– Path coverage = 4
38
Reading Assignment
A. Basis Path Testing
B. Logic Based Testing
C. Data flow testing
D. Gray box testing
39
Any Question?
40