0% found this document useful (0 votes)
35 views29 pages

Adhoc Testing for Banking Application

The document describes designing test cases for an automated banking application using different black box testing techniques like boundary value analysis (BVA), robust BVA, worst BVA and robust worst BVA. It provides examples of test cases for area code, prefix, suffix and password using these techniques. The test cases cover minimum, maximum and boundary values to test the application under different conditions.

Uploaded by

Manju
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)
35 views29 pages

Adhoc Testing for Banking Application

The document describes designing test cases for an automated banking application using different black box testing techniques like boundary value analysis (BVA), robust BVA, worst BVA and robust worst BVA. It provides examples of test cases for area code, prefix, suffix and password using these techniques. The test cases cover minimum, maximum and boundary values to test the application under different conditions.

Uploaded by

Manju
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

AIM: Program statement 1

Consider an automated banking application. The user can dial the bank from a personal
computer, provide a six-digit password, and follow with a series of keyword commands that
activate the banking function. The software for the application accepts data in the following
form:

Area Code Blank or three-digit number


Prefix Three-digit number, not beginning with 0 or 1
Suffix Four-digit number
Password Six-character alphanumeric
Commands "Check status", "Deposit", "Withdrawal"

Design adhoc test cases to test the system.

DESCRIPTION:
Adhoc Testing:
When a software testing is performed without a prior knowledge on the application and without
any planning and documentation is know as Adhoc Testing.
Forms of Adhoc Testing:
1) Buddy Testing : One Tester and one developer mutually work with an intention to find
the defects in the application
2) Pair Testing: Two testers involve in this method.
3) Monkey Testing: Testing will be performed without any test case in order to break the
application.
In simpler words, Adhoc testing is nothing but exploring the application.

TESTCASE:

Test Case Scenario Description Expected Results


No:
1 User calling the bank User dial the bank from pc Connection estab-
lished
2 User enter area code Enter blank/3digit number Area code accepted
3 User enter prefix Enter 3 digit num/not start- prefix accepted
ing with 0 or 1
4 User enter suffix Enter 4 digit number Suffix accepted
5 User enter password Enter 6 digit password Password accepted
6 User click on check sta- User checks status of ac- Account status dis-
tus count played
7 User click on deposit User wants to deposit Deposit successful
money
8 User click on withdrawal User wants to with-drawal Withdrawal successful
AIM: Program statement 2
Consider an automated banking application. The user can dial the bank from a personal
computer, provide a six-digit password, and follow with a series of keyword commands that
activate the banking function. The software for the application accepts data in the following
form:

Area Code Blank or three-digit number


Prefix Three-digit number, not beginning with 0 or 1
Suffix Four-digit number
Password Six-character alphanumeric
Commands "Check status", "Deposit", "Withdrawal"

Design the test cases to test the system using following Black Box testing technique:
BVA (Boundary Value Analysis), Worst BVA, Robust BVA, Robust Worst BVA

DESCRIPTION:
BVA: ( Boundary Value Analysis ) :
The basic idea of BVA is to use input variable values at the minimum, just above the minimum, a
nominal value, just below their maximum and at their maximum. Meaning thereby (min, min+,
nom, max-, max+).

Robust BVA:
In BVA we remain within the legitimate boundary of our range i.e. for testing we consider values
like (min, min+, nom, max-, max) whereas in Robustness testing, we try to cross these legitimate
boundaries as well. Thus, for testing here we consider the values like (min-,min,min+,nom,max-
,max,max+)

Worst BVA:
If we reject our basic assumption of single fault assumption theory and focus on what happens
when we reject this theory-it simply means that we want to see that what happens when more
than one variable has an extreme value. In electronic circuit analysis, this is called as “worst-case
analysis”. We use this idea here to generate worst-case test cases. For each variable, we start with
the five element set that contains the min-,min, min+, nom, max-, max, max+ values. In addition
to this we will be having min--,max++,min++,[Link] then take the Cartesian product of these
sets to generate test cases.

BVA FOR AREA CODE:

TEST CASE ACTION/SCENARIO INPUT ACTUAL EXPECTED


NO:
1 enter area code NULL/Blank area code is area code is ac-
accepted cepted
1.1 enter min code 000(min) area code is area code is ac-
accepted cepted
1.2 enter min+ area code 001(min+) area code not area code is ac-
accepted cepted
1.3 enter nominal area 555(nom) area code is area code is ac-
code accepted cepted
1.4 enter area code just be- 998(max) area code is area code is ac-
low max accepted cepted
1.5 enter area code max 999 area code is area code is ac-
value accepted cepted

BVA FOR PREFIX:

TEST CASE ACTION/SCENARIO INPUT ACTUAL EXPECTED


NO:
2 Enter (min)prefix 200 Prefix is accept- Prefix is accept-
ed ed
2.1 Enter prefix(min+) 201 Prefix is accept- Prefix is accept-
ed ed
2.2 Enter nominal 700 Prefix is accept- Prefix is accept-
ed ed
2.3 Enter just below max 998 Prefix is accept- Prefix is accept-
ed ed
2.4 Enter prefix max 999 Prefix is accept- Prefix is accept-
ed ed

BVA FOR SUFFIX:

TEST CASE ACTION/SCENARIO INPUT ACTUAL EXPECTED


NO:
3 Enter (min)Suffix 1000 Suffix is accept- Suffix is accept-
ed ed
3.1 Enter suffix(min+) 1001 Suffix is accept- Suffix is accept-
ed ed
3.2 Enter nominal 1700 Suffix is accept- Suffix is accept-
ed ed
3.3 Enter just below max 9998 Suffix is accept- Suffix is accept-
ed ed
3.4 Enter suffix max 9999 Suffix is accept- Suffix is accept-
ed ed

BVA TEST CASE FOR PASSWORD:

TEST CASE ACTION/SCENARIO INPUT ACTUAL EXPECTED


NO:
4 enter pwd which is less as34d(min) Password not Password ac-
than 6 alpha numeric accepted cepted
keywords charecters
4.1 enter pwd which is less as34ac Password ac- Password ac-
than 6 alpha numeric cepted cepted

4.2 enter pwd which is as34klojac Password not Password ac-


nominal ie.,7-11 alpha- accepted cepted
numeric charecters
4.3 enter pwd which is of as34kacsghtk Password not Password ac-
max charecters(11) accepted cepted

4.4 enter pwd which>12 as34acsghtssk Password not Password ac-


charecters accepted cepted

ROBUST CASE FOR AREA CODE:

TEST CASE AC- INPUT ACTUAL EXPECTED


NO: TION/SCENARI
O
1 enter area code NULL/Blank area code is area code is ac-
accepted cepted
1.1 ENTER min- code -1 area code is area code is ac-
not accepted cepted
1.2 enter min code 000(min) area code is area code is ac-
accepted cepted
1.3 enter min+ area 001(min+) area code is area code is ac-
code not accepted cepted
1.4 enter nominal area 555(nom) area code is area code is ac-
code accepted cepted
1.5 enter area code just 998(max) area code is area code is ac-
below max accepted cepted
enter area code 999 area code is area code is ac-
1.6 max value accepted cepted
1.7 enter area code 1000 area code is area code is ac-
max+ value not accepted cepted

ROBUST CASE FOR PREFIX:

TEST CASE ACTION/SCENARIO INPUT ACTUAL EXPECTED


NO:
2 enter prefix (min-) 199 prefix not accept- prefix is accept-
ed ed

2.1 enter prefix(min) 200(min) prefix is accepted prefix is accept-


ed
2.2 enter (min+) prefix 201(min+) prefix is accepted prefix is accept-
ed

2.3 enter nominal prefix 700 prefix is accepted prefix is accept-


ed

2.4 enter prefix just below 998 prefix is accepted prefix is accept-
max ed

2.5 enter prefix of max 999 prefix is accepted prefix is accept-


value ed

2.6 enter prefix of max+ 1000 prefix not accept- prefix is accept-
value ed ed

ROBUST CASE FOR SUFFIX:

TEST CASE ACTION/SCENARIO INPUT ACTUAL EXPECTED


NO
3 enter suffix (min-) 199 suffix not accept- suffix accepted
ed

3.1 enter suffix (min) 200(min) suffix accepted suffix accepted

3.2 enter (min+) suffix 201(min+) suffix accepted suffix accepted

3.3 enter nominal suffix 700 suffix accepted suffix accepted

3.4 enter suffix just below 998 suffix accepted suffix accepted
max
3.5 enter suffix of max 999 suffix accepted suffix accepted
value
3.6 enter suffix of max+ 1000 Suffix not accept- suffix accepted
value ed

ROBUST CASE FOR PASSWORD:

TEST AC- INPUT ACTUAL EXPECTED


CASE NO TION/SCENARIO
4 enter pwd which is less as34(min) pwd not ac- pwd accepted
than 5 alpha numeric cepted
keywords characters
4.1 enter pwd which is less as34d(min) pwd not ac- pwd accepted
than 6 alpha numeric cepted
keywords characters
4.2 enter pwd which is as34ac pwd accepted pwd accepted
equal to 6
4.3 enter pwd which is as34klojac pwd not ac- pwd accepted
nominal ie.,7-11 alpha- cepted
numeric characters
4.4 enter pwd which is of as34kacsghtk pwd not ac- pwd accepted
max characters(11) cepted
4.5 enter pwd which>12 as34acsghtssk pwd not ac- pwd accepted
characters cepted
4.6 enter pwd which>13 as34acsghtssks pwd not ac- pwd accepted
characters cepted

WORST CASE FOR AREA CODE:

TEST ACTION/SCENARIO INPUT ACTUAL EXPECTED


CASE NO
1 enter area code NULL/Blank area code is ac- area code is ac-
cepted cepted
1.1 enter min—code -2 area code not
accepted
1.2 enter min- code -1 area code not area code is ac-
accepted cepted
1.3 enter min code 000(min) area code is ac- area code is ac-
cepted cepted
1.4 enter min+ area code 001(min+) area code not area code is ac-
accepted cepted
1.5 enter nominal area 555(nom) area code is ac- area code is ac-
code cepted cepted
1.6 enter area code just be- 998(max) area code is ac- area code is ac-
low max cepted cepted
1.7 enter area code max 999 area code is ac- area code is ac-
value cepted cepted

1.8 enter area code max+ 1000 area code not area code is ac-
value accepted cepted

1.9 enter area code max++ 1001 area code is not area code is ac-
value accepted cepted

WORST CASE FOR PREFIX:

TEST ACTION/SCENARIO INPUT ACTUAL EXPECTED


CASE NO
2 enter min—prefix 198 prefix not ac- prefix is accept-
cepted ed
2.1 enter prefix (min-) 199 prefix accepted prefix is accept-
ed

2.2 enter prefix(min) 200(min) prefix accepted prefix is accept-


ed

2.3 enter (min+) prefix 201(min+) prefix accepted prefix accepted

2.4 enter nominal prefix 700(nom) prefix accepted prefix accepted

2.5 enter prefix just below 998(max-) prefix accepted prefix accepted
max

2.6 enter prefix of max 999(max) prefix accepted prefix accepted


value

2.7 enter prefix of max+ 1000 prefix is not prefix accepted


value Accepted
2.8 enter prefix 1001 prefix is not prefix accepted
max++value accepted

WORST CASE FOR SUFFIX:

TEST ACTION/SCENARIO INPUT ACTUAL EXPECTED


CASE NO
3 enter min-- suffix 998 suffix not ac- suffix accepted
cepted
3.1 enter (min-)suffix 999 suffix not ac- suffix accepted
cepted
3.2 enter(min)suffix 1000(min) suffix accepted suffix accepted

3.3 enter(min+)suffix 1001(min+) suffix accepted suffix accepted

3.4 enter nominal suffix 1700(nom) suffix accepted suffix accepted

3.5 enter suffix just below 9998(max-) suffix accepted suffix accepted
max
3.6 enter suffix of max 9999(max) suffix accepted suffix accepted
value
3.7 enter suffix of max+ 10000 suffix not ac- suffix accepted
value cepted
3.8 suffix of max++ value 10001 suffix not acept- suffix accepted
ed
WORST CASE FOR PASSWORD:

TEST CASE ACTION/SCENARIO INPUT ACTUAL EXPECTED


NO
4 enter pwd which is less as3 pwd not ac- pwd accepted
than 4 alpha numeric cepted
keywords characters
4.1 enter pwd which is less as34 pwd not ac- pwd accepted
than 5 alpha numeric cepted
keywords characters
4.2 enter pwd which is less as34d(min) pwd not ac- pwd accepted
than 6 alpha numeric cepted
keywords characters
4.3 enter pwd which is 6 as34ac pwd accepted pwd accepted
alpha numeric key-
words characters
4.4 enter pwd which is as34klojac pwd not ac- pwd accepted
nominal ie.,7-11 alpha- cepted
numeric characters
4.5 enter pwd which is of as34kacsghtk pwd not ac- pwd accepted
max characters(11) cepted

4.6 enter pwd which>12 as34acsghtssk pwd not ac- pwd accepted
characters cepted

4.7 enter pwd which>13 as34acsghtssks pwd not ac- pwd accepted
characters cepted

4.8 enter pwd which>14 as34acsghtsskss pwd not ac- pwd accepted
characters cepted

ROBUST WORST CASE FOR AREA CODE:

TEST CASE AC- INPUT ACTUAL EXPECTED


NO: TION/SCENARI
O
1 enter area code NULL/Blank area code is area code is ac-
accepted cepted
1.1 ENTER min- code -1 area code is area code is ac-
not accepted cepted
1.2 enter min code 000(min) area code is area code is ac-
accepted cepted
1.3 enter min+ area 001(min+) area code is area code is ac-
code not accepted cepted
1.4 enter nominal area 555(nom) area code is area code is ac-
code accepted cepted
1.5 enter area code just 998(max) area code is area code is ac-
below max accepted cepted
enter area code 999 area code is area code is ac-
1.6 max value accepted cepted
1.7 enter area code 1000 area code is area code is ac-
max+ value not accepted cepted

1.8 enter min-- code -2 area code not


accepted
1.9 enter area code 1001 area code is area code is ac-
max++ value not accepted cepted

ROBUST WORST CASE FOR PREFIX:

TEST CASE ACTION/SCENARIO INPUT ACTUAL EXPECTED


NO:
2 enter prefix (min-) 199 prefix not accept- prefix is accept-
ed ed

2.1 enter prefix(min) 200(min) prefix is accepted prefix is accept-


ed

2.2 enter (min+) prefix 201(min+) prefix is accepted prefix is accept-


ed

2.3 enter nominal prefix 700 prefix is accepted prefix is accept-


ed

2.4 enter prefix just below 998 prefix is accepted prefix is accept-
max ed

2.5 enter prefix of max 999 prefix is accepted prefix is accept-


value ed

2.6 enter prefix of max+ 1000 prefix not accept- prefix is accept-
value ed ed

2.7 enter min-- prefix 198 prefix not accept- prefix is accept-
ed ed

2.8 enter prefix 1001 prefix is not ac- prefix accepted


max++value cepted
ROBUST WORST CASE FOR SUFFIX:

TEST CASE ACTION/SCENARIO INPUT ACTUAL EXPECTED


NO
3 enter suffix (min-) 199 suffix not accept- suffix accepted
ed

3.1 enter suffix (min) 200(min) suffix accepted suffix accepted

3.2 enter (min+) suffix 201(min+) suffix accepted suffix accepted

3.3 enter nominal suffix 700 suffix accepted suffix accepted

3.4 enter suffix just below 998 suffix accepted suffix accepted
max
3.5 enter suffix of max 999 suffix accepted suffix accepted
value
3.6 enter suffix of max+ 1000 Suffix not accept- suffix accepted
value ed

3.7 enter min-- suffix 998 suffix not accept- suffix accepted
ed
3.8 suffix of max++ value 10001 suffix not acepted suffix accepted

ROBUST WORST CASE FOR PASSWORD:

TEST AC- INPUT ACTUAL EXPECTED


CASE NO TION/SCENARIO
enter pwd which is less as34(min) pwd not ac- pwd accepted
4 than 5 alpha numeric cepted
keywords characters
4.1 enter pwd which is less as34d(min) pwd not ac- pwd accepted
than 6 alpha numeric cepted
keywords characters
4.2 enter pwd which is as34ac pwd accepted pwd accepted
equal to 6
4.3 enter pwd which is as34klojac pwd not ac- pwd accepted
nominal ie.,7-11 alpha- cepted
numeric characters
4.4 enter pwd which is of as34kacsghtk pwd not ac- pwd accepted
max characters(11) cepted
4.5 enter pwd which>12 as34acsghtssk pwd not ac- pwd accepted
characters cepted
4.6 enter pwd which>13 as34acsghtssks pwd not ac- pwd accepted
characters cepted
4.7 enter pwd which>14 as34acsghtsskss pwd not accept- pwd accepted
characters ed

4.8 enter pwd which is less as3 pwd not accept- pwd accepted
than 4 alpha numeric ed
keywords characters
AIM: Program statement 3
Consider an application that is required to validate a number according to the following simple
rules:
1. A number can start with an optional sign.
2. The optional sign can be followed by any number of digits.
3. The digits can be optionally followed by a decimal point, represented by a period.
4. If there is a decimal point, then there should be two digits after the decimal.
5. Any number-whether or not it has a decimal point, should be terminated a blank.
Generate test cases to test valid and invalid numbers.
(HINT) Use Decision table and cause-effect graph to generate test cases.

DESCRIPTION:
Decision table is another useful method to represent the information in a tabular method. It has
specialty to consider complex combinations of input conditions and resulting actions. Decision
table obtain their power from logical expressions. Each operand or variable in a logical
expression takes on the value TRUE or FALSE.

DECISION TABLE

CONDITION RULE-1 RULE-2 RULE-3 RULE-4 RULE-5 ACTION


Sign Valid T T T T X
Number F Valid T T T X
Decimal F F Valid T T X
Two digit after F F F Valid T Improper
decimal/period (I)
Terminate as F F F F Valid Improper
blank (I)

CAUSE-EFFECT GRAPH TO GENERATE TESTCASES


Yes Yes N
Number having
Optionally
Number start It should be two (2) values INVALID
followed by (.)
with sign numeric after decimal
No No symbol No yes

INVALID INVALID VALID Terminated


as blank
as
AIM: Program statement 4
Generate test cases using Black box testing technique to Calculate Standard Deduction on
Taxable Income. The standard deduction is higher for tax payers who are 65 or older or blind.
Use the method given below to calculate tax.
1. The first factor that determines the standard deduction is the filing status. The basic standard
deduction for the various filing status are:
Single $4,750
Married filing a joint return
$9,500
Married filing a separate return
$7,000
2. If a married couple is filing separate returns and one spouse is not taking standard
Deduction, the other spouse also is not eligible for standard deduction.
3. An additional $1,000 is allowed as standard deduction, if either the filer is 65 yrs or the spouse
is 65 yrs or older(the latter case applicable when the filing status is “Married” and filing “joint”).
4. An additional $1,000 is allowed as standard deduction, if either the filer is blind or the spouse
is blind (the latter case applicable when the filing status is “married” and filing “joint”).
(HINT):
From the above description, it is clear that the calculation of standard deduction depends on the
following 3 factors:
1. Status of filing of the filer
2. Age of the filer
3. Whether the filer is blind or not
In addition, in certain cases, the following additional factors also come into play in calculating
the standard deduction.
1. Whether spouse has claimed standard deduction
2. Whether spouse is blind
3. Whether the spouse is more than 65 years old

USER IS SINGLE

TESTCASE AC- INPUT ACTUAL EXPECTED


NO TION/SCENARIO
1 user is single AGE<65;Earning<$4750 NO tax de- TAX deduc-
duc- tion
tion/Tax
paid
1.1 user is single AGE<65;Earning>$4750 NO tax de- TAX deduc-
duc- tion
tion/Tax
paid
1.2 user is single AGE>65;Earning<$4750 TAX de- TAX deduc-
duction tion
1.3 user is single AGE>65;Earning>$4750 TAX de- TAX deduc-
duction tion
1.4 user is single & Blind AGE<65;Earning<$4750 TAX de- TAX deduc-
duction tion
1.5 user is single & Blind AGE<65;Earning>$4750 TAX de- TAX deduc-
duction tion
1.6 user is single & Blind AGE>65;Earning<$4750 TAX de- TAX deduc-
duction tion
1.7 user is single & Blind AGE>65;Earning>$4750 TAX de- TAX deduc-
duction tion

USER IS MARRIED AND JOINT RETURN

TEST- AC- INPUT ACTUAL EXPECTED


CASE NO TION/SCENARIO
2 user married filling AGE<65;Earning<$9500 NO tax de-
joint duction/Tax TAX deduc-
paid tion
2.1 user married filling AGE<65;Earning>$9500 NO tax de- TAX deduc-
joint duction/Tax tion
paid
2.2 user married filling AGE>65;Earning<$1050 Tax deduc- TAX deduc-
joint 0 tion tion
2.3 user married filling AGE>65;Earning>$1050 TAX deduc- TAX deduc-
joint 0 tion tion
2.4 user is married & AGE<65;Earning<$9500 TAX deduc- TAX deduc-
Blind tion tion
2.5 user is married & AGE<65;Earning>$9500 Tax deduc- TAX deduc-
Blind tion tion
2.6 user is married & AGE>65;Earning<$1050 TAX deduc- TAX deduc-
Blind 0 tion tion
2.7 user is married & AGE>65;Earning>$1050 TAX deduc- TAX deduc-
Blind 0 tion tion

USER IS MARRIED AND FILLING A SEPARATE RETURN

TESTCASE AC- INPUT ACTUAL EXPECTED


NO TION/SCENARIO
user is married & AGE<65;Earning<$7000 NO tax de- TAX deduc-
3 separate duction/Tax tion
paid
3.1 user is married & AGE<65;Earning>$7000 NO tax de- TAX deduc-
separate duction/Tax tion
paid
3.2 user is married & AGE>65;Earning<$7000 Tax deduction TAX deduc-
separate Higher tion
3.3 user is married & AGE>65;Earning>$7000 Tax deduction TAX deduc-
separate Higher tion
3.4 user is married & AGE<65;Earning<$7000 Tax deduction TAX deduc-
separate return & Higher tion
Blind
3.5 user is married & AGE<65;Earning>$7000 Tax deduction TAX deduc-
separate return & Higher tion
Blind
3.6 user is married & AGE>65;Earning<$7000 Tax deduction TAX deduc-
separate return & Higher tion
Blind
3.7 user is married & AGE>65;Earning>$7000 Tax deduction TAX deduc-
separate return & Higher tion
Blind
AIM: Problem Statement 05
Consider the following program segment:
1. int max (int i, int j, int k)
2. {
3. int max;
4. if (i>j) then
5. if (i>k) then max=i;
6. else max=k;
7. else if (j > k) max=j
8. else max=k
9. return (max);
10. }

a) Draw the control flow graph for this program segment


b) Determine the cyclomatic complexity for this program
c) Determine the independent paths

Control Flow Graph:

5 4 7

10
10
6 8

Cyclomatic Complexity:
It is a software metric used to indicate the complexity of the program. It is used to get the
independent paths (test cases) used for unit testing.
Cyclomatic complexity = Number of edges – Number of nodes +2
Here,
Cyclomatic complexity = 10 – 10 + 2 = 2
Mean there are two independent paths.
Independent Paths:

1 1

2 2

3 3

5 4 4 7

6 9 9 8

10 10
AIM: Problem Statement 06
Source code of simple insertion sort implementation using array in ascending order in c
programming
Language

#include<stdio.h>
[Link] main(){
[Link] i,j,s,temp,a[20];
[Link] ("Enter total elements: ");
[Link] ("%d",&s);
[Link]("Enter %d elements: ",s);
[Link](i=0;i<s;i++)
7. scanf("%d",&a[i]);
[Link](i=1;i<s;i++){
9. temp=a[i];
10. j=i-1;
11. while((temp<a[j])&&(j>=0))
12. { a[j+1]=a[j];
13. j=j-1;
}
14. a[j+1]=temp;
}
[Link]("After sorting: ");
[Link](i=0;i<s;i++)
17. printf(" %d",a[i]);
[Link] 0;
}

HINT: for loop is represented as while loop


a) Draw the program graph for given program segment
b) Determine the DD path graph
c) Determine the independent paths
d) Generate the test cases for each independent path
a) Program graph:

DD Path graph: ( Decision to Decision ) -


Cyclomatic complexity is a source code complexity measurement that is being correlated to a
number of coding errors. It is calculated by developing a Control Flow Graph of the code that
measures the number of linearly-independent paths through a program module.

Lower the Program's cyclomatic complexity, lower the risk to modify and easier to understand.
It can be represented using the below formula

Cyclomatic complexity = E - N + P where,


E = number of edges in the flow graph.
N = number of nodes in the flow graph.
P = number of nodes that have exit points
Independent Paths :
The number of edges is represented by e, the number of nodes by n and the number of connected
areas by p.
V(G) = e – n + p = 11 –8 + 3 = 6
1) a,b,d,i
2) a,b,c,d,i
3) a,d,c,d,e,f,h,d,i
4) a,b,c,d,e,f,g,h,d,i
5) a,d,d,e,f,h,d,i
6) a,b,d,e,f,g,h,d,i
Test Cases:
Test Case1:
1) Input ‘s’ value as ‘-1’ and see ‘s’ value is displayed properly
2) See “After sorting” statement is printed.

Test Case 2:
1) Input ‘s’ value as 0 and see ‘s’ value is displayed as 0 or not
2) See “After sorting” statement should be displayed.

Test Case 3:
1) Input ‘s’ value as 1 and see ‘s’ value is displayed as 1 or not
2) Enter a value = 10
3) See “After sorting 10” statement should be displayed.

Test Case 4:
1) Input ‘s’ value as 2 and see ‘s’ value is displayed as 2 or not
2) Enter a value = 10
3) Enter another value = 20
4) See “After sorting 10 20” statement should be displayed.

Test Case 5:
5) Input ‘s’ value as 2 and see ‘s’ value is displayed as 2 or not
6) Enter a value = 20
7) Enter another value = 10
8) See “After sorting 10 20” statement should be displayed.
AIM: Problem Statement 07
Consider a system having an FSM for a stack having the following states and transitions:

States
1. Initial: Before creation
2. Empty: Number of elements = 0
3. Holding: Number of elements > 0, but less than the maximum capacity
4. Full: Number elements = maximum
5. Final: After destruction
6. Initial to Empty: Create
7. Empty to Holding, Empty to Full, Holding to Holding, Holding to Full: Add
8. Empty to Final, Full to Final, Holding to Final: Destroy
9. Holding to Empty, Full to Holding, Full to Empty: Delete
10. Design test cases for this FSM using state table-based testing.

DESCRIPTION:
State Transition testing, a black box testing technique, in which outputs are triggered by
changes to the input conditions or changes to 'state' of the system. In other words, tests are
designed to execute valid and invalid state transitions.
AIM: Problem Statement 08
Given the following fragment of code, how many tests are required for 100% decision coverage?
Give the test cases.
if width > length
then biggest_dimension = width
if height > width
then biggest dimension = height end_if
else if biggest dimension = length then
if height > length
then biggest_dimension = height end_if
end_if end_if
Hint 04 test cases

Test Cases:
1) Width > Length
biggest_dimension = width
Height > Width
biggest_dimension = height
Final Output: biggest_dimension = height

2) Width > Length


biggest_dimension = width
Height < width
Final Output: biggest_dimension = width

3) Width < Length


Biggest dimension = length
Height > length
biggest_dimension = height
Final Output: biggest_dimension = height

4) Width < Length


Biggest dimension != length
Final Output: biggest_dimension = null
AIM: Problem Statement 09
Given the following code, how much minimum number of test cases is required for full
statement and branch coverage?
read p read q
if p+q> 100
then print "Large" endif
if p > 50
then print "p Large" endif
Hint 1 test for statement coverage, 2 for branch coverage

DESCRIPTION:
Statement Coverage: It is the first kind of logic coverage criteria can be identified in the form
of statements. It is assumed that if all the statements of the module are executed once, every bug
will be notified. The test cases should be in such a way that all the statements in a program
should be covered

Branch Coverage:Decision coverage or Branch coverage is a testing method, which aims to


ensure that each one of the possible branch from each decision point is executed at least once and
thereby ensuring that all reachable code is executed. That is, every decision is taken each way,
true and false. It helps in validating all the branches in the code making sure that no branch leads
to abnormal behavior of the application.

Test Cases:
Statement Coverage:

1) Read p and q value

2) If p+q > 100 then print Large

Eg:
P=60
Q=50 i.e., 110>100

3) If p > 50 then print p Large

Eg:
P=60 i.e., 60>50
Branch Coverage:

To calculate Branch Coverage, one has to find out the minimum number of paths which will
ensure that all the edges are covered. In this case there is no single path which will ensure
coverage of all the edges at once. The aim is to cover all possible true/false decisions.
A1-B2-C-3D-4E
A1- B3-D

Hence Decision or Branch Coverage is 2.


AIM: Problem Statement 10
Consider a program to input two numbers and print them in ascending order given below. Find
all du paths . Also find all dc paths and generate the test cases for all paths .

#include<stdio.h>
#include<conio.h>
1. void main ()
2. {
3 int a, b, t;
4. Clrscr ();
5. Printf (“Enter first number”);
6. scanf (“%d”,&a);
7. printf(“Enter second number”);
8. scanf(“%d”,&b);
9. if (a<b){
10. t=a;
11a=b;
12 b=t;
13}
14. printf (“%d %d”, a, b);
15 getch ();
}

DESCRIPTION:
Data Flow Testing: Data flow testing is a family of test strategies based on selecting paths
through the program's control flow in order to explore sequences of events related to the status
of variables or data objects. Dataflow Testing focuses on the points at which variables receive
values and the points at which these values are used.

Data Flow testing helps us to pinpoint any of the following issues:

 A variable that is declared but never used within the program.

 A variable that is used but never declared.

 A variable that is defined multiple times before it is used.

 Deallocating a variable before it is used.


CONTROL FLOW GRAPH: DATA FLOW GRAPH:

1 1

2 2

3 3:Define

5,6 5,6:
Define,use

7,8

7,8:
Define,use
9

9
10,11,12

10,11,12:
14 Define,C use

14

DEFINITION AND USAGE NODES:

VARIABLE DEFINED AT USED AT


A 3,5,6 9,10,11
B 3,7,8 9,11,12
T 3 10,12

Data Flow Testing Paths:


All du paths : Line 3-6 Line 9-11,Line 3-8 Line 9-11, Line 3&10
All dc paths : Line 3&10, Line 3&11, Line 3&12
AIM: Problem Statement 11
Consider the above program and generate possible program slices for all variables. Design at
least one test case from every slice.

DESCRIPTION:
• Program slice is a decomposition technique that extracts statements relevant to a particu-
lar computation from a program
• Program slicing describes a mechanism which allows the automatic generation of a slice
• Program slice must satisfy the following conditions
• Slice S(V,n) must be derived from P by deleting statements from P
• Slice S(V,n) must be syntactically correct
• For all executions of P, the value of V in the execution of S(V,n) just before the location n
must be the same value of V in the execution of the program P just before location n

SLICE 1:
void main ()
{
int a, b, t;
Clrscr ();
printf(“Enter second number”);
scanf(“%d”,&b);
printf (“%d %d”, a, b);
getch ();
}
SLICE 2:
void main ()
{
int a, b, t;
Clrscr ();
printf (“Enter first number”);
scanf (“%d”,&a);
printf (“%d %d”, a, b);
getch ();
}

You might also like