Een 8 RET
1 Black'box testing is a software tes PY
| evaluates the functionality of an ae tethod Where
| internal code, structure, or i an application without key
input and output—h oF implementation detaiie tre sng sl
1 i put—how the system beh ails. The foous is
\ internally. haves ratherthan hominy
eee vow it sets
‘ ee se vs
Black box testing identifies the following kind of errors :
e Incorrect or missing functions
e _ Interface errors
e — Errorin data model
e Errorin external database access
Performance errors
e Initialization and termination errors
various test cases are designed to test the software
During the black box testing,
of test case consist of input value,
techniques have been derived t
me of black-box technique:
expected output andactual
systematically. Each
10 do the black box testing
output. obtained. Various
of any software product. Sol
Jass testing
s are:
iy Equivalence ©
(i Boundary value analysis
{iii Decision table testing
(iv) Cause-effect graphs
2.2 When to Use Block,
+ rT 0S +
Black box testing is useful 9 following scene"
1. During Functional Testing features wo expect
; -ation’s fea!
nar an apptication®
To check whet!ee
‘During Functional
Testing
fying
imple? verifyin!
ear accepts
alod credential =
valli id During System
and © jects invall Testing
ones:
ste!
2, during sy For User
Testing Acceptance Testing
qo evaluate
overall sySt0% =
base For Regression
pehavior Testing
requirement
example nsung
n online payment For Security and
gateway processes Performance Testing
transact! ons
correctly:
3, For user Acceptance Testing (VAT)
To confirm the software meets business needs before deployment.
Example :A banking apP undergoes UAT to ensure users can transfer funds
securely.
4, For Regression Testing
To make sure new, changes do not break existing functionality.
Example : Testing anve-commerce checl
5, For Security and Performance Testing
ies without accessing the internal logic.
To test vulnerabl
kout after adding a discount feature.
'
E : ingi
:xample : Checking if a website prevents unauthorized access to user data.
Equivale! i
quivalence class testing (or Equivalence Partitioning)
Equivalence partitioni
partitic is
ofa neem i is ablack box testing method that divides the input dome!"
lasses of data from which test cases can be derived. Thes?
e derived. Thes
classes are kr
nown as equi
juivi
quivalence classes. In a equivalence class each membé!
(2
of cl2®
10 an
pelo"
with
Test
clas
inv
nut
Eqguides nouns
pr
moot the small,
cequivale
soonest,
F
range or 119 est 22808 10M th
Rather than
@
outputs v ‘= B
Guidelines f es a
«i
J w
Sao
test cases should & re
ps 2 numbers. Values jus r
v fore
N) pws
Example
et boundaries (e.g. an arta ‘an ATM 2
M4 seal ta structures tesa oT er
foe pesadefna it 20 000) then design atest case to exercise the datz step |:
Feast exotureat is boundary
wwe F
Example eo
ep 2:
‘Avwebsite allows users 10 register if their age IS between 18 and 60 (inclusive)
()Age<18 : Registration fails Te
(i) 18< Age < 60: Registration passes T
T
1
(lil) Age> 60; Registration fails
Step 1: Identify Boundaries
he key boundary values are, 18 and 60 (since th fine the valid rang?
I : (si ey defin 9
{26
eeint
20%
_ the customer is a memt
ember and spend
1
( giscount
_ ifthe customer is not a me
member and spends $ 2
i) Feediseount:
cathe customer is not a member
ef and spends § 50 -T)
giscount.
w
exemple (Login Authentication System)
gystem has t!
ifthe username i
he following login rules
is correct an ord rect, login suce
\d the password is correct, login si
, login success,
0
@
@
username i
ifthe name is correct but the password is incorrect, |
login fails.
ifthe username is incorrect, login fails (regardless of pa:
ss of password)
Identify Conditions & Actions
step 1+
ect
Username is cor"
Password is correct
Login Success
Login Fails
e Decision Table
Step 2: Create thi
Test | Username (U) password (P)
Case
Yes e
Yes Se
No Yes
No Mstem
yeen
hout
sea
le is
tinct
min tie entry portion of the tabi
Masarul
A
aaiion On column are known
e as inputs an
sare Known AS outputs. Output ae a
ot s are calculat ,
lated depondi
‘eal cations of the program.
example
cn an example of a typical Decis
mn table shown in Table. Tt
‘able, The inputs in this
ple derive th le} vat cond i
Y the outputs depending on what
ditions these
al ese in
Po table’, "—" represents
a presents the don't care entries.
TABLE
Rulet | Rulez | Rules \ Ruled I Rules
; = : ; \ Rules
F a 1.
T T Bj
iT E A
x x a
R
x
into a test case
leis converted i
the decision tabl
ponding t°
gix text cases correst
entry portion of
‘six ‘columns | in
ple, there are
decision table.
Each Golumn in the
Therefore in this exam
the entry portion of the
Example
An e-commerce website Pr2 *
400, they get 2
vo tnan § y
(the customer Is member and puys Mm PA set W) gise?
tess, they ge
discount. ends g100 or A 104, 403"
member put 8? ay ee
qo _ Wthe customer isa gretnan s100:theY et aad 5%
discount. porbut epon™ 8, i Pcs
mem! '
qu) the customer is not® se 100 oF 88 —— 0) Woe
discount. mber ‘and spe” 09
(wv) tthe customer IS not ame
discount. exo
step1: 1¢! Cyst
o
TO) Mf
purchase? 7 $ a \
action
20% Discount ..
e'
40% Discount step
5% Discount
No Discount
ision Table
Create the Dec!
step2:
No Discount
(D0)
jiscount | 5% Discount
Salen 20% Discount | 10%D
Salen (p10)
Step3:
fep3: Execute and Verify
(i) Tetsif
the custor
diseaintt mer is amember and spends $ 150 -Th
-They should get a 20%
[30]By testing right at the pouncarle®
Correctly Handlos Himlt cond nor \
hips between
yes ical
od LE cos0* 191
ple-bas
gw ued cases. without
1 of t8t
Decison abiebaee I ia
. jot
comp! go we US
input data yoo pul ® “got qroato 108 cases We USC a
motte noe such a table
A docision Table * tne ait rogram is
ae oirsotl ai ues of 2P 2)
sing the intemal an
nthe |
jon ni0 i 1
: |
doois
jour oat
pit up int 18
FIGURE 2-2
.d two vertical parts resulting in four distinct
‘The table js divided into two porizontal an'
The quadrants are usuall
sled Conditon stub deals with the given. conditions and th
oh e
areas or quadrants: ly separted by double lines. The left
and of upper portion cal
‘night hand of upper portion call
condition, Ia condition is true, ther it
, then we write Y or T against i
xX OF Le itotherwise N
or F. The
lled Condition Entry deals with the truth value of
\ r ore
{eft hand side of I i io)
ig of lower portion of the decision table is called Acti ib
portion enlists all the pos i i t —
eae Cae actions. The right hand side of lo is
wer portion is c:
alled
Action Entry, if
fan action is to be
{able then a mark ) cae
Vv}
: enc. E upper portion of the
ropriate colum
in otherwise it is lef
[28]
oe
ov
4
ongelect Test Cases.
_Input (Age)
17
18
19
59
60
61 a
Execute and Verity
step 3?
(i) Ifentering 17 then we get output as fall
(ji) Ifentering 18 then we get etiotl a 5
(i) Hfentering 19 we get output as pass
(iv) Ifentering 59, we get output as pass
(v) Ifentering 60 we get output as pass
(vi) Ifentering 61 we get output as fail
ample (ATM Withdrawal Limit)
Ei
ls between Rs. 100 and Rs. 5000 (inclusive),
An ATM allows withdrawal:
Identify Boundaries
Step 1:
(i) Minimum withdrawal: Rs. 100
(i), Maximum withdrawal: Rs. 5000
Step 2: Select Test Cases
Expected Output
Input (Amount)
Fail (Too low)
Pass
Pass
Pass
Fail (Too high)gfetass behaves in similar fashion, s
Sotestir
NING the
cod
n equivalence class is ag ¢
&S good
to al
pelonging to that equivalence cig 5 testing the
So the ,
the output vith an
within a equivalence Class will bo « ha
similar Ot testing 1,”
oF diferent v- >
testcase design for equi
ses for an rote re eattioning isbe
cl wut condition, A, ased oy
‘ = . An @ Nan eva
invalid states for input conditions ativalees lass op Valuation of equ
i » Typically resents
numeric value, a range of v: IY, AN ing set of
haa alues, a put Condit Of valid of
s » € Set of icy eee eS
Equivalence classes may be defined a elated values, or at, either a specific
Ccording * OF a boolean cong
4, _ Ifan input condition specifies a r: to the following guideline tion,
ange, oni 2 ee
defined.
1@ valid an SSeS are
id and two invalid classe:
Ae
For example, if an i i
ple, Hen input condition specifies a rar
identify one valid equivalence class [1
- 99} ee
fom 1 to 99, we
and two invalid equivalence
2, If an input condi i
y put condition requires a specific value, one valid and t
equivalence classes are defined. 3 esate
If an input condition specifies a member of a set, one valid and one invalid
hs li li
equivalence set are. defined.
4, Ifaninput condition is boolean, one valid and one invalid class are defined.
delines for the derivation of equival
lata item could be developed al
st number of attributes of anequival
Applying the gui lence classes, test cases for
each input domain d
selected so that the large
ind executed. Test cases 27°
lence class is exercised
at once.
fe tions:
; d gistration system with the following conditior
re
Awebsite has an age-base
() Users below 18
en 18 and 60 yeal
ars are not
(i) Users betwe (231
(i) Users above 60 yean 15 characters : Invalid (Too tong)
an Mere th
1 jaentity Equivalence Classes
8 step 1
ut Range Expect al uieseehe casas
a ne pected Outcome | Equivalence Class
Username <5 chars Invalid
Invalid Class
5 < Username < 15 chars| Valid
~~ = Valid Class
ysemame > 15 chars Invalid
Invalid Class
vq. gtep 2? select Test Cases
—4 Input (Username) Expected Output
—| “abe” Invalid
“user123" Valid
“thisisaverylongusername” Invalid
Step 3: Execute and Verify
et e Enter “abe”: Should display “Invalid Username.”
e Enter “user123” = Should allow login.
1 e Enter “thisisaverylongusername” + Should display “Invalid
Username”
fect
2.4 Boundary Value Analysis
A greater number of errors occurs at the boundaries of the input dom ae
lary value analysis (BVA) has bee
in the “center”. It is for this reason that bound
developed as a testing techni
mming errors occul
ng valence
rat the boundaries of different equivale!
. (251
Some typical progral
(e
—_Testing or pehavioral Testing,
ofthe output for
which produces
nas Function@!
hich involves onl
jalyZe
gis also know!
refers to testing, W
nd there is neattempt to an
ure of the program isignored? For this
ich the content ofa
black box testing in whit
Jack box is understood completely in terms
Black-box testin
the code,
reason, functional
Functional testing
certain inputvalues, al
the output. The internalstruct
testing is sometimes referred to as @
black box isnot known and function of bl
of its inputs and outputs as shown in figure.
Output domain
Input domain
Input test System
under Output test
data
data
test
heater eee FIGURE 2.1
and what output the system “uh st Sarena can be ot
cases in functional testing i euiiglve:in other words, th a ae
ial ig is.the requirements or see i.
pecifications of the system of
[20]
ee Cdpartitions) Where We ox,,
oups (I :
into a"
Equivalence Class
Invalid Class
valid Class
Invalid Class
ses 4 step 2
eet select Test cm avery possible a2, we select representative value,
dof test r
LF ch equivalence class : Te
Expected Output T
1
7
Tet iS
30. .
Tc2 Step
Tc3 65
Step3: Execute and Verify
Run the test cases and check if the system behaves as expected.
This technique reduces the number of test cases while ensuring effective
coverage, E
Pai 2.4 Bi
Exe
: ‘ample A
login system a i
ccepts us in
Tee, PIS Usemames between 5 to 15 characters.
es 'an 5 characters : Invalid cs
() Sto15 ‘Invalid (Too short)
Characters - s
Valid username
[24]xocute a9 rll
steps ae a
ect use e apasewor Login ne ot
@ Tet a
erect U0" arn
Login should fait
- Login should fail
_ Login should fail
arttioning and boundary value analysis
equivalence class P
phing is @ technigy
Aweakness of
they do not consider combinations of MPU; Cause-effect ort
inations of input condi
tions in a systematic manner
that helps in selecting combi
oftest cases do not become large.
ifying causes and effects of th
effect is a distinct output condition,
that number:
.e system under testing
This technique starts: with identi
distinet input conditions and an
Acause is 2
ffects, for each effect we identify the causes tha
‘Atter identifying the causes and et
can produce that effect and how the ‘conditions have to be combined to make the
effect rue, Conditions are combined using the Boolean operators “and,” "or", an
i ani
‘not,* which are represented in the graph ind ~{The mi 1 fo
ie graph by &,!, and i
Hh } basic symbols used fv
dre
rawing cause-effect graph are shown in figure.
8&8
Varnot we
Boolean operators te AND: a
example occ.
dito hou
Let the various causes (°F ine Sie >
the various effects (of action§ re Ey" os
table.
causes
Effect
so the cause
Finally,
Advat
Thec
e
°
e
FIGURE 2.4ye
S asily
in table Y Converted ino
he
wihis cause-effect araph can i
TABLE
Rulet
| Ruler |
<* | Rutes |
°
9°
Causes
9
oO
aaadada
|
oO
my
m
Effects
m
m
Finally, each columns of the decision table is converted into a test case.
Advantages :
The cause effect graph technique has the following advantages
Number of test cases reduced.
e High yield test cases.
e Helpsin understanding the functionality of the system.
7 Advantages of Block Box Testing :
Advantages are :
1. Effective for large systems en
i nits of code than white -
More effective on larger UIe
29
[Block Box
Testing
vantages are:
¢ Not Identify Internat
1 code lssues
Gannot detect memory
joaks, logic errors, oF code
inefficiencies.
2 pifficult 3 2 aa
Without clear and concise 8% o
neti o Unnes
specifications, test cases = % \ Se innecesaary
are very difficult to design Seen ane eA)
a : a
BemsUnnecessery Frepetition MiG col earner
| eanenee
| caments of Code
there may be unnecessary
repetition of test inputs if the
Difficult to
i Identify Edge Cases
tester is not informed that
programmer has already
tried these test cases.
4, Not Cover All Segments of Code Code Cheats
May leave many program paths untested.
5, _ Difficult to Identity Edge Cases
ster only sees inputs and outputs, unexpected edge cases may
since the te
be missed.
Repeated Testing
If functionality changes, tes!
After Code Changes
6.
ent updates:
t cases may need frequi
White Box testing oF Structural Testing or Glass Box
Testin
Incase of fun
details are being
e code 1S nidden ane no
internal im
deals with testing the
tional testing,
ntrast to this, WI
tested, inceHelps to
expose Ambiguities | unne
~ Ther
y Easy Test ep?
E cases Design test!
pro
Helps Find Oy
Missing Requirement | 4. No
Me
ee. Dl
4, Focuses on Use
re done froma US
Ambiguities
6 F
Tests al er's point of view.
5, Helps to expose
slack box testing wil help to expose any ambiguities or inconsistencies int
specifications.
6. EasyTest cases Design
Test cases can be designe as soon as the speci ications are complete +a
7. Helps Find Missing Requirement =
Since tests are bi
ased on specificati issil i pe
specifications, missing or incorrect requireme d i
eta
can be detected early,Se a ane ate pa
7
ensures thorough Code
coverage
white box testing aims to
test every Possible path,
condition, and merenent
within the code. This ensures
that no part of the code
remains untested, reducing
the risk of hidden defects,
identifying Hidden Bugs
white box testing helps
detect logical errors,
jncorrect conditions, and
missing j paths that may not
be caught by black box
testing. It ensures that all
possible execution paths are
reducing the
¢ of unexpected
tested,
chance!
software failures.
Early Bug Detection
By exal
helps identify and
resolve.
Improves Code Quality
By identify!
the softwar
Strengthens Security
Ituncovers security vull
mining the code early in
fix bugs before
edundant code, Wi
ing inefficient orr
mance, reliability,
e for better perfo
2
£
3
&
a Strengthens
@ Security
= roe
= Validates Logic >
and Design
Facilitates Continuous
Improvement.
| Enh
Be cates )
Collaboration
Supports
Automation
the development process, white box testing
they become more complex and costly to
Ihite Box Testing helps optimize
and maintainabilly
points inthe code that could
(39)roup of various struct
ndopendent structures of the pre
>on
jules or the program. ”
wr
program 18 4.9!
est cases are based on followin guidelines
paths within a module haye
chnique based
Awnite box testing te
g _ Atestcase should ensure thatall the independe
’ been visited at least once._,
(i) Logical or Boolean conditions (or decisions) must be exercised on their true
and false sides.
i Loops must be executed for their poudary (edge) values as shown in
figure.
|
Valid Boundary Values’
Invalid Boundary Values
\
FIGURE 2.5
(iv) Internal
nal data structures of cod VY,
le must be exercised to ensure their valid
3 r validly.
{ 38)@ based on
the control flow of th
} of @ program is consid
ered and ¢
Jet us first consider a control flow graph (
raph (or sir
(OF simply tic
W graph) o
re
oa
oro! flow graph (or Flows graph)
ie
a, shows logical control fl
no" 9 low using the following notation
ae
While-do Repeat until Switch (or case) |
If-then-else
FIGURE 2.7
We can make the flow graph from flowchart or from the source code of module (or
program).
Nodes rep!
links between
node. A path is a seque!
path is a path whose first node
independent path of a program Pis the pat
one new processing condition.
resent a single statement or group of statements. Edge represents the
itions are referred to as predicate
nodes. A node that contains conditio
nce of nodes from a specific node i to node j. A complete
is start node and last nod
h that ensure that path co
le is exit node. An
ntains atleastyotdeheckEven(intnum) (
iyqnum % 2 == 0) { // Statement 1
print{(*Ever\n’);// Statement 2 1
\
}
print(("Done\n"); // Statement 3
\
}
int main() {
checkEven(4); // Covers all statements \
\
return 0;
ee: num =4 Covers all three statements in this example.
umitatton* Does nott
nt
est both true and false branches.
03 Branch Coverage Criteria (or Testing)
Inbranch coverage criteria, suitable 2 testa case ate designed to execute each branch
cision at leasLonce: So, text case are designed such that the different
; branch conditions are given true and fal
asbythename ofall-edge criteria. tis det
auc ie
arantees state!
| penoted that branch coverage guara
an the statement coverage:
known
of each de
Ise values in turn. This criteria is also
noted by the symbol Cy,anen It must also
ment coverage, and hence this is a
That is why itis symbolically
stronger testing criterion th
represented asfail
—
is that
ANique
ner so
sting.
dition.
s that
e the
, and
2d for
32]
FIGURE 2.3
Gause-effect graphing technique has following steps
i
(a) Various mocu" jodules in the system are identified
Ve fic
tions to be
(b) For each of the module, identify various input conditions and th
taken corres} :
ponding to these input conditions. Various input conditions
jons are
called cause and actions corresponding to it is called effect. Hence, in this
. Hence, in th
step, causes and effects are listed for each module.
(c) Draw cause-effect graph..
(d) Transform cause-effect graph into: decision table:
(e) Convert decision table into fest cases)
ig nodes are used to represent.
In Gause-effect graph variou!
() The input conditions or causes
[33]
(i) Effects of conditions+ protection against pote,
5, Thi
logic, and do,
algorithms,
ss of
aves as intended unde,
°F a
e correctnes
a tenting PoE 16 software bel
rations, ensuring
f
0
Th
implement
improvement
y of tests to source code, enabling
traceabill
ent cycles.
future developm
ation
ing of the codebase, reducing
pth understand
1d between developers and testers while ensuring
ers gain an in-der
communication overned
ality goals.
alignment on a!
tion
‘supports Automal
10 the detailed knowledge of
mated efficiently due t
repetitive testing scenarios,
Test cases can be autor
and resources in
intemal structures, saving time
2.11 Classification of White Box Testin,
Classification of white box testing is shown in figure.
White box Testing
Control Flow-
based Testing
Data flow:
based Testing
Condition
Covers ull ees
or Path Testing moe
Statement | |B:
Co ranch
[ neue. | | Coverage
Coverage
FIGURE 2.6
[40]ve
figure f
peso om, ae
ve
neuoeplicieese <
Draw 8
step (
2.12
FIGURE 2.8
F in figure is
Jomatic complexity of flowgraph a Bed.
step2 oye ule): Pade a
va) = EN :
= 10-842 a
if fc
Step3 As V(G)=4, therefore independent paths are 4 as shown below :
Pant: 1-2-8-8
Pathe; 4-2-4-8
Path ; 1-5-6-8
Path4 ; 1-5-7-8
Step 4 Prepar i
Pare test cases that will force executions of each path.
Limitation : Path
+ Paths incre i
crease, ©xponentially for large programs,
(4
oOC—O —<_—— =
ased testin,
sonra tow
0d toting: Ont"
Let us now consider the control flow-ba |
(a) Statement coverage
(b) Branch coverage |
1
(c) Condition Coverage
\
(d)~ Path coverage
Testing)
iteria (or Tes &
erage criteria Pe.
2.12.2 Statement Coveras ce. sik aie 5 |
ee sais a iteria and is also known a8 all-nog, |
J statos that each & na
casos. Itis the simp! ee
F ent coverage criteria I
teria, Statement o¥e729
e 4
X=
Example
yelow :
Consider the program segment givon be
while (x > 50 && y < 10)
|
I
|
I
| Sum=x+y;
i
| printf ("%d", Sum) ;
!
|
x=xt1
In this segment, the test case of x=51 and y=9 will cover all the statements.
However this testing does not. guarantee that the test program will behave correctly "
for all input values,
[42]Example
Consider the program seg
i roar aN
if(a> 0 && b> 0)(
! printf(Both Positive\n");
}
}
int main() {
checkValue(1, 1); // True, True
checkValue(1, -1); // True, False
checkValue(-1, 1); // False, True
checkValue(-1, -1); // False, False
return 0;
y
eet
() (1,1): True, True
(i) (1) :Tue, False
(iii) (1,1 : False, True
: False, False
dition is tested for both outcomes
Does not check combinations. of multiple c
(iv) Cr
Each cont
Limitation:
ment given below :
if (x > 50 && y < 10)
{
Sum=x+y>
printf ("%d"; sum) +
x=x+ts
onditions.ample -—
exam — —rydo 6088) 10) 3
condlton (> ,
51 y=9
x25 i
‘a rogram
all the branches of given prog }
are enough to cove *
fashio
iter sting)
1 iteria (or Tes!
a.12.5 Path Coverage C7 a . oe
i that all independent Pa!
Tn ey tetora no cated m ERED criteria and deny cons
i
feast once, That is why this cr
with the symbol Cpa :
y itis symbolically represe,,
path coverage implies branch coverage. That is Wh)
i
Path coverage testing has the following steps +
1. Using the design or code as a foundation, draw a corresponding flow gray 2.
2. Determine the cyclomatic complexity of the resultant flow graph. x
4.
! Cyclomatic Ie
1 lomatic complexity, V(G), for a flowgraph (G) is defi
ze Wee Noa (G) is defined as
I fhere Eis the number of flowgraph ed,
I Nis the number of flowgraph fades ny
¢
| Def 2:
I GQ
'yclomatic complexity, V(G;
, V(G), fe i
/ Wa) srs (G), for a flowgraph (G) is defined as
Where P is the number o i
K f predicate Nodes contained on a flowgraph G
Se(a) Execute one pass through the looP i k
(v) Execute two passes through the HooP Soseien "
wi ci
(c) Execute x passes through the (00P: E
Execute n-1) net, passes through the
(@) xect 1,
(e) Skip the looP entirely.
Example a -~
( TT ginctude
I
I yoidloopTestcint n) {
! for (inti = 0; i<
I printf(“%ed “is
7 )
| printf(“n");
1 }
|
1
! int main() {
JoopTest(0); // Zero iterations ° \
/ loopTest(1); //One iteration . .
! JoopTest(3); // Multiple iterat ions
; return 0;
| }
| _ ee |
Test cases:
() N= (Loop never runs)
N=1 (Loop runs once)
N=3(Loop runs multiple times)
Lim
tation: Cannot test infinite loo
(8ot
tages of Path Testin,
g Advantag
12: pdvantages ae:
4, Pathtesting wil detect majority o Ht
ee | PREM Hh part of cose,
2.
3, _Allindependent paths deteg
4.
The errors discovered are varying, Ey,
may not get the same result,
eryone
0 does b;
5, _ Itis helpful for testing of code thatis not
yet ready §
pseudocode or an algorithm Written for t
IO 8xecution
he program,
7 Loop Testing
. st of the algorithms are implemented by using loops. There!
oe be paid for testing the loops. Loop testing is a white box testin
‘hm i There are following four
jn idity of loop constructs. g
ly on the vali
exalusive
imple Loops
1. \
Figure of simple loop is ‘shown in figure.
Ig!yy
Example
2.
TT inc |
( #include
|
|
Nested Loops
Ma loop contain
of nested loo, MET loop, 4
od loop is sh . then thay
teen gu ne
FIGURE
In case of nest =
ted loop, the number Of possible tect
tests would gr
Set of tests
as the level of nested increased. The followir
‘i wing
nested loops. be applied to
(a) Start at the innermost loop. Set all other loops to minimum vah
(b) Conduct simple loop tests for the innermost loop,
(c) Work outward, conducting tests for the next loop, but keepi
‘outer loops at minimum values and other nested loops to ty
(d) Continue until all loops have been tested.
jinamatnx
alculate the sum of all elementsin@ .
ea ols, int ations)
C
// Functio! ‘
ax(int rows: inte@
4g, Determine a basis set oy
thy provides the number oj,
he structure. “AY indope,
4. Prepare test cases that wy,
Data shoule be chosen gq a xc
My 89 tha Not
appropriately set as each
| compared to expected ros,
Path is tec,
Uults, eae
jrisimportantto note that some ind,
pend
fashion. In such cases, these path. me
‘Snt path
Example
tested as py,
onsider the © Program to fin heroes: nu
side est number tron
f 4, | #include < studio, h> east
| main ()
SEntey A
int a,b,c;
seanf ("%d %d%d", &a, &b, 2c);
if (a>b)
{
A if (a>c)
aan s printf (‘Largest no.=%d", a);
else
—
5
printf (Largest no.= %c!.c);
else
a
alld
if (b> °)
2%", b);
printf ("Largestno-= " 4
1
= printf Largest adi
(4—
3.
Concatenated Loops
Concatenated loops M!
figure
FIGURE 2.11
‘ed loops, testing depends upon interdependence
re independent of one another then they can be
ps are interdependent, then they should be
In the case of concatenate
among the loops: If loops al
tested one after the other. But if loo}
tested in the same way aS nested loops.
Example
#include
\
//Function with concatenated loops
void il
! ProcessArray(intarr{], int size) { :
\|
| cases fe
iZ tae P
ia OP exec)
lf Matrix Scution path
if
I :
|
' elements
nit
i , a" {15}
I | je Row Execution)
; } 4c3(5in9! fe,
I
inglecolumn Execution)
| rea (sing (1,2), 81)
| i.
Execution)
| rosqworme’ ) ((1,21,6,4))
{(1,2,3}, (4.5.6),
789))
7c6 (Full Execution -
Large Matrix)
Coverage Analysis
jon Case : Ensures that ifr
iteration Case Ensures the smallest possible loop execu!
ows = 0 or cols = 0, NO Joop runs.
tion (1x1
Nested Loop
(i) Zero Iterat
(ii) Minimum t
matrix).
(ii) Partial Execution Cases -Test cases with 4petike execution (single ro"
ies i ‘i ormal or large
(iv) Normal & Large Execution: Covers all loop iterations inane 1"
matrix. elin
int sum = 0;
int product = 1;
1/ First loop: Calcuta
for (inti = 03 i< size; i44) SUM Of olomont,
sum += ani};
}
printf(‘Sum of array elements
edn", sum)
+ Sum),
4 Second loop: Calculates produc
for (inti = 0; i< size; iss) ( ie
product *= afi};
elements
}
printf(“Product of array elements:
}
int main() {
int size;
// Taking input for array size
printf(“Enter array size: “);
scant(“%d", &size);
intarr[size];
/ Taking input for array elements
printf(“Enter array
for (inti = 0; i< sizes i++) (
Mop? &artlil)s
elements:\n’);
scanf(
}
edn", product);ypouter 1ooP
yinner loop.
0; ‘
= 0; Fe rows zs
cols: 4) {
for(int
°
for (inti =
sum += matrixf0li
:
)
return sum
)
int main() (
int rows, cols;
zp Taking input for matrix size
print(“Enter number of foWS: ";
96d", &rows);
scant('
number of columns: “5
printf(“Ente
scant(“%ed", &cols);
int matrix[rows][cols];
// Taking input for matrix elements
printf(“Enter matrix elements:\n’);
for (inti = 0; is rows; i++) {
for (intj = 0; | < cols; j++) {
scanf("%d", &matrix{ilfj);
}
Calculating sumpairvotured LOOP
H Fa toope ynich do not follow any of the above mont
I typos) 2 led unstructured looy /
ype
ad
FIGURE 2.12
lect the u
Whenever possible this type of loops should be redesigned to ref
of the structured programming constructs
2,13 Data flow Based Testing
Data flow based testing focuses on the definitions of the variables and where the
¥ this testing scheme is to check the
definitions are being used. The basic purpose Oo!
chnique to detect human
variables and their subsequent usage. This is a best te
variable without defining it, a programm
errors like programmer may use @ val
defined a variable but don't initialised it and used it in predicate logic
ner has
[57]
siaemmCalling function
processArray(arr
return 0;
\
)
,
|
I
1
|
|
|
I
ee
Coverage
Test Cases for Concatenated 100P
es and values.
coverage, Wo test
different array Siz
To ensure full looP
Loop
Execution
Test Case ID
No loop
‘execution
¢1 (Zero Iterations)
(gum & product
not computed)
gum = 6, Product = 5 Each loop rung
7¢2(Minimum Iteration) ce
= 6, Product ='6
7ca{Normal Execution) | 3:{1.2 3} sum =6,
Each loop runs 3
times
TC4 (Negative Values) 3, {-1, 2, -3}
Gum=-2,Product=6 | Each loop runs
times
TC5 (Large Input) 5, (1,2,,4,5}
Sum = 15, Product = 120 | Each loop runs §
times
Concatenated Loop Coverage Analysis —
(i) Zero Iterations Case : Ensures the function handles an empty array.
(ii) Minimum Hteration Case : Ensures the loops run exactly once.
numbers,
(iv) Large Input Cases ;
Ss : Ensures pet
Tre performance and Correctness with largernt assignments
| pesti@ ge
22 Ad yes 0) Data Flow re Bees corn
2.13.3 Advantages of Data FIOM god tes dl | _
») petectsuninitialized VA ig
; pncy bY fos 4 .
mproves test efficion’y ae
” code execution. incomion oP |
: \ ical error™ .
‘ii) Hel ssidentify logic® a white Box Tes
WHITE BOX 42.
13°
itrequires i
45:
46
igses ON input-output
functions:
with reference to
ment.
3. Itfocus
values!
4, Testing is done
user's functional require!
end-users
5, Performed by testers
or QA teams.
itis done at early stage of
" testing:
Itfocusses on program
3. structure and data structure
ea ;
4, Testing is done with referengg,,
the code and standards use.
5, Performed by Developers
Testers.
ee
Esecise ___@~7 a2
ih
When to use Black-box testing?
What do you mean by Black-box testing? Explain.
Explain equivalence Class Testing by using example.
Explain Boundary Value Analysis by using example.
Write advantage; ind disadys - sting
ages and disad ‘antages of black. box testi
:
2
3
4.
5. Explain Decision Te
fable-bi i i
; ased testing by using example.
7.
What do you mean by white.
8 ft
What are Needs of White-box
box testing? Explain
testing?oqutod peeuy 8 Busy) ‘WOH /) $9= de
peay sind // ‘(nd)eed |
|
\((qu)yoozis)ooyjew = nd, IU!
} (ougAoWwew plor i
ajdwiexy
|
+(Miowaw pee,y “*6"e) pier seBuo} OU Ss} }! 48He ejqeea e Bush,
(n/-p) palini Buea Jeyy pasn elqeHEA ©
{
(enjen sayy Bujsn jnouyim)'e jo Zjed// OL =
ejoljoay ig=e tut
} (quewubissyjuepunpe: pIoA
ajdwiexs
uuBISsY
-enjen snoinaid s}1 Bulsn e10jaq ejqewen op enien® 6
(p-p) esp nowy UoRUaPeH S14eHEA 4
{
s)x OWNS // 4 ',P%,)HUNE
ix quy
y por
op Buleg 1c
) Qajdurex=uoue pion
ne bus
Ugg jou sey yey elgeH?”
pe!
+a
(98-9 |, 19Q) *
(osp-a i. sea) (0 <9\
0 ‘P%,)aund
939 989-9 17 '¢ + q=o1y |
|
I
I
!
I
‘(.u\@aneBeny, )yund
} asye {
‘(,U\@AnIsog, auld
939 esN-d// }(O<4q)y
qjoseay/ ‘z,e=qqui
} (e 1uejduiexe pion
ajdurex3
xa ‘Painsexe s} (ued na) Ye esn-oj-WoRIUYEp A1ane Jeu} sosnsuZ
aBeseao0g syjed-Nd ily
ssV
yen
(
z@
(esn-o) z.4=2
0
(esp) (01 ize
uscg al i \
Initia = | 5; 1
abIeg eel I oid testFunotion(int x, int y){ ‘
a ! intz=x+¥ /] (Def of 2)
~ 1
8 Pr !
mn fa | f(z> ort // (P-Use of 2) \
0,
svi t printf(“Positive\n"); 1
I jelse { \
! printf(‘Negative or Zero\n’); \
\
ations, | )
|
resent i }
pu Chain for 2:
Feber 2 =X + ¥>
g, P-Use: if (z> 0) (zis used for decision-making).
le x}
E Data FlowTesting checks if all variables are properly defined before use.
Set ‘| |
| 13.1 Types of Data F low Testing Coverage
| 4, AlkDefinitions Coverage
Ensures every variable definition is covered by at least one test case that
reaches a usage point.
Example :
inta=10; // Def ofa
printf(“2%q", a); // Use of a
t where ais defined
overt Test case should execute the statemen and used.
2 All-Uses Coverage
Ensures every use of a variable is covered in test cases.
r [591
58