Professional Documents
Culture Documents
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
1 Prefix Three-digit number, not beginning with 0 or 1 4
Suffix Four-digit number
Password Six-character alphanumeric
Commands "Check status", "Deposit", "Withdrawal"
Design adhoc test cases to test the system
Design the test cases to test the above application using the following Black Box testing techniques:
2 BVA, Worst BVA, Robust BVA, Robust Worst BVA, Equivalence class testing 11
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.
3 6. A number can start with an optional sign.
7. The optional sign can be followed by any number of digits.
8. The digits can be optionally followed by a decimal point, represented by a period.
9. If there is a decimal point, then there should be two digits after the decimal.
10. Any number-whether or not it has a decimal point, should be terminated a blank. Generate test cases to test
valid and invalid numbers.
Generate test cases using Black box testing technique to Calculate Standard Deduction on 24
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
4
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
4. An additional $1,000 is allowed as standard deduction, if either the filer is blind or the spouse is blind.
Consider A program segment which calculates the maximum value among three integers. 30
a) Draw the control flow graph for this program segment
5 b) Determine the cyclomatic complexity for this program
c) Determine the independent paths.
36
For a Source code of simple insertion sort implementation using array in ascending order in c programming
language,
6
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
7 Consider a system having an FSM for a stack having the following states and transitions: 41
States
• Initial: Before creation
• Empty: Number of elements = 0
• Holding: Number of elements > 0, but less than the maximum capacity
• Full: Number elements = maximum
• Final: After destruction
For a given fragment of program code, calculate the number of tests required for 100% decision coverage? Also 44
8 write the test cases.
Given the following code, how much minimum number of test cases is required for full statement and branch 48
coverage?
read p read q
9 if p+q> 100
then print "Large" endif
if p > 50
then print "p Large" endif
Consider a program to input two numbers and print them in ascending order given below. Find all du paths and 55
Identify those du-paths that are not feasible. Also find all dc paths and generate the test cases for all paths (dc
10
paths and non dc paths).
Consider the above program and generate possible program slices for all variables. Design at least one test case 57
11 from every slice.
Consider the code to arrange the numbers in ascending order. Generate the test cases for relational coverage, loop 60
coverage and path testing. Check the adequacy of the test cases through mutation testing and also compute the
mutation score
for each.
i = 0;
12 n=4; //N-Number of nodes present in the graph
While (i<n-1) do j = i + 1;
While (j<n) do
if A[i]<A[j] then swap (A[i], A[j]); end do;
i=i+1;
end do
Exp No-1:-
PROBLEM STATEMENT:-
Consider an automated banking application. The user can dail 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.
DESCRIPTION:-The testing with no proper test cases and planning is known as adhoc
testing. It is generally performed at the end of the project completion before submission. Here
were are performing a type of adhoc testing called pair testing where there are two teaters as a
pair while one is writing test cases , other will be performing the test.
TEST CASE1:
111 accepted
TEST CASE2:
abc accepted
ANALYSIS:-defects found
TEST CASE3:
TEST CASE1:
TEST CASE2:
231 accepted
TEST CASE1:
40a accepted
TEST CASE1:
9489 accepted
TEST CASE2:
12ab accepted
TEST CASE3:
TEST CASE1:
1@bcd1 accepted
TEST CASE2:
12345a accepted
TEST CASE3:
123456 accepted
Check status:
TEST CASE1:
TEST CASE2:
Deposit:-for a normal undergraduate account, max deposit is 50000/- and min deposit is 1000/-
TEST CASE1:
TEST CASE2:
Withdraw:-minimum amount in the account should be 100 and max withdraw should not
exceed 5000/- at a time minimum balance present is 10,000/-
TEST CASE1:
TEST CASE2:
Exp No-2:-
Consider an automated banking application the user can dial the bank form a personal computer
provide a six digits password and follows with a series of keyword command that activated the
banking application accept data in the following them:
Area code Blank of three digits number
Prefix Three digits number not beginning with 0(or)1
Suffix Four digits number
Password Six character alphanumeric
Commands “Checkpoint” “Deposit” “Withdrawal”
Description:
In black box testing there are two cases
Test Data:
min 0
max 123
Min+1 1
Min-1 -
Max+1 1234
Max-1 12
Min+ Max/2 23
Testcase1:
Analysis: No defects in the test case .So test case will be closed.
Testcase2:
Testcase3:
Test Data:
min 234
max 034
Min+1 2345
Min-1 23
Max+1 345
Max-1 03
Min + Max/2 345
Test Case Scenario2:
Testcase1:
Testcase2:
Testcase3:
Test Data:
min 1111
max 1142
Min+1 11115
Min-1 111
Max+1 11423
Max-1 114
Min+ Max/2 1134
Testcase1:
Testcase2:
Testcase3:
Test Data:
min Abcd12
max 1142ab
Min+1 Abcd123
Min-1 Abcd1
Max+1 1142abc
Max-1 1142a
Min+ Max/2 Abc123
Testcase1:
Testcase2:
Testcase3:
Check status:
Min 1124
Max 2341
Min+1 11241
Max+1 12341
Min-1 112
Max-1 234
Min+ max/2 1124
Test case 1:
Analysis: No defects in this test case so we can close the test case
Test case2:
Analysis: No defects in this test case so we can close the test case
Test case for deposit: minimum and maximum inputs are as follows
Min=10,000
Max=40,000
Min 1124
Max 2341
Min+1 11241
Max+1 12341
Min-1 112
Max-1 234
Min+ max/2 1124
Test case 1:
Analysis: No defects in this test case so we can close the test case
Test case2:
Analysis: No defects in this test case so we can close the test case
Test case for withdrawl: minimum and maximum inputs are as follows
Min=100
Max=500
Min 100
Max 500
Min+1 501
Max+1 1001
Min-1 499
Max-1 999
Min+ max/2 775
Test case 1:
Analysis: No defects in this test case so we can close the test case
Test case2:
Analysis: No defects in this test case so we can close the test case
Test case 1:
Test case 2:
427 1111
Test case 1:
Test case 2:
Test case 1:
Test case 2:
Test case 3:
Test case 1:
Test case 2:
Test case 3:
Test case 1:
Test case 2:
Deposit: for a normal under graduate account , max deposit is 50000 and maximum deposit is
1000
Test case 1:
Test case 3:
60000 Accepted
10 accepted
Maximum with drawl should not exceed 5000 at a time minimum balance present is 10000
Test case 1:
Test case 2:
- Not Accepted
Test case 3:
Exp No-4:-
Generate test case 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 maximum.
1. The first factor that determines the standard deduction is filling status the basic standard
deduction the various filling standards are:
single $4,750
Married filing or join $9500
return
Married filing or join $7000
return
2. If a married couple is filing separate returns and one spouse is not taking standard deduction.
The other spouse also is not elgible for standard deduction.
3. An additional $1000 is allowed as standard deduction, if either the file is 65years or the spouse
is 65years or older (the latter case applicable when the filing status is married and filing joint).
4. An additional $1000 is allowed is standard deduction, if either the filter is blind or the spouse
is blind (the latter case applicable when the filing status is married and filing joint).
Aim: to calculate standard deduction for tax payers by using black box testing.
Description:
Black box testing is a method of software testing that examines the functionality of an
application without peering into its internal structures or workings. This method of can be
applied to virtually every level of software testing unit, integration, system and acceptance.
Min=max 65
Min-1 65-1=64
Max+1 65+1=66
blind
Min=max 4750
Min-1 4750-1=4749
Max+1 4750+1=4751 Test case 1:
Test case 2:
60 rejected
Analysis: No defect test case2 can be closed
Test case 1:
Test case 2:
$4749 rejected
Analysis: No defect test case 2 can be closed
Test case 3:
Join-Return: $9500
Test case 1:
Test case 2:
Test case 3:
Test case 1:
Test case 2:
Test case 3:
Rule 2: if one spouse is not taking standard deduction also not eligible.
Min=max Both
Min one
Test case 1:
Test case 2:
Test case 3:
Min=max 65
Max+1 65+1=66
Min-1 65-1=64
Test case 1:
Test case 2:
Test case 3:
Rule 4: $1000 if allowed if either the filter is blind or the spouse is blind.
Min=max 2
Min-1 2-1=1
Test case 1:
Test case 2:
Test case 3:
Viva questions:
Exp No-5:-
2. {
3. int max
4. if(i>j)then
5. if(i>k)then max=i;
6. else max=k;
8. else max=k
9. return(max);
10. }
AIM:
To draw the control flow graph to calculate the cyclomatic complexity and independent
path for given problem.
DESCRIPTION:
a1 4. printf("%d",x); count=count-1
4. printf("%d",x);
1
2
2 3 1
A control flow graph represents the execution path with in a program code. It covers
selective, iterative, sequence statements in a given code.
Cyclomatic complexity:
It is a metric used for measuring the complexity of a given program code with respect to
dependent and independent paths in a control flow graph (coupling and cohesion). It can be
calculate in three ways:
1. The total number of predictive node is equal to the cyclomatic complexity of the program.
3. By calculating the total number of nodes and edges in the control flow graph using formula:
no. of edges-no. of nodes+2(E-N+2)
Independent path:
Independent path through the program it introduces at least one new edge that is not
included in any other path before it.
p1:1->2->3->8->9
p2:1->2->3->4->5->6->7->9
p3:1->2->3->4->5->6->5->9
Program:
5
7
9 6 8
10
b. cyclomatic complexity:
E-N+2
=12-10+2
=2+2
=4
c. independent paths:
path1:1->2->3->4->5->9
path2:1->2->3->4->5->6->9
path3:1->2->3->4->7->8->9
path4:1->2->3->4->5->7->8->9
Viva Questions:
Exp No-6:-
Aim: Source code of simple insertion sort implementation using array in ascending order in c
programming language.
Description:
#include<stdio.h>
int main ()
Temp=a[i];
j=i-1;
a [j+1] =a[j];
j=j-1;
a [j+1] =temp;
Return o;
Test scenario:
7
for for
8
100100
111
12
13 while
for
141
151
161
171
181
191
20
21
22
for
23
24
25
Rules:
1) Single node with in deg=0.
2) Single node without deg=0.
3) Single node with in deg>=2 or out deg>=2;
4) Single node in deg=1 out deg=1.
5) Maximal chain of length>=1.
1 2 3 4 5 6 18
Test case1:
Input Output
i=1 True
Test case2:
Input Output
i=6 True
Test case1:
Test case2:
Input Output
i=6 False
VIVA QUESTIONS:
1) What is Sorting?
2) What is DD path?
3) What is Independent path?
Exp No-7:-
Consider a system having FSM for a stack having the following states and transactions
States:
Empty: no of elements=0
Delete
AIM: To write a test case for a system having FSM for a stack
Test case: 1
Condition:
Test case: 1
Elements=0 true
Capacity=3
Test case: 1
Elements=0 false
Test case: 2
Condition:
Transaction:
coin coin
push Locked Unlocked
pus
h
initial
Condition: add
Test case: 1
Elements: 3 unlocked
Test case: 2
Elements: 2 unlocked
Test case: 3
Elements: 4 locked
Test case: 4
Elements: 3 locked
Condition:
Initial
add
Empty Holding
delete
delete add
delete delete
destroy
Final Full
destroy
Exp No-8:-
AIM:
Given the following fragment of code. How many tests are required for 100% decision
coverage? Give the test cases
Then biggest_dimension=width
Biggest_dimension=height
End-if
Then biggest_dimension=height
End-if
End-if
End-if
Code segment:
If(width>length)
Biggest_dimension=width;
If(height>width)
Biggest_dimension=height;
Else if (dimension=length)
If(height>length)
Biggest_dimension=height
Description: to every decision condition should be in test cases is called 100% decision
coverage.
Testcase1:
input output
10>6 true
Condition: biggest_dimension=width=10
testcase1:
input Output
3>10 False
Testcase1:
input output
10>6 true
biggest_dimension=width=10
Condition: height>width
Testcase1:
input output
15>10 true
biggest_dimension=height=15
Condition: width>length
Testcase1:
input output
10>6 true
biggest_dimension=width=10
Testcase1:
input output
15>16 true
Condition: width>length
Testcase1:
input output
10>11 true
Dimension=length
Testcase1:
input output
6=6 true
Height>length
Testcase1:
input output
15>6 true
Flowchart:
Width>height true
Width>length false Dimension=lengt
h
false
true
fals
Biggest_dimension= Height>length
false
height
Exp No-9:-
Aim:
Give the following code,how much minimum number of test cases required for full statement
and branch
Out of coverage.
loop Biggest_dimension=h
Read pread 2
eight
Out of loop
If p+q>100
End if
If p>50
#include<stdio.h>
Int p,q;
Printf(“enter p:”);
Scanf(“%d”,&p);
Printf(“enter q:”);
Scanf(“%d”,&q);
If(p+q>100)
Printf(“large”);
Else
Printf(“small”);
If(p>50)
Printf(“plarge”);
Else
Printf(“psmall”);
Description:
The statement coverage also known as line coverage or segment coverage.The statement
coverage along the true conditions.Through statement coverage we can identify the statements
executed and where the code is not executed because of blockage.In this process each and every
line of code needs to be closed and executed.
Branch testing:
It is a testing method which aims to ensure that each one of the possible branch from each
decision point executed atleast once and there by ensuring that all reachable code executed.
That is every branch taken each lay 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.
1 Read p,q
p
5
P is large
9 13
13
10 14
14
15
11
1
16
16
18 22
18 22
24
III Year II Sem Software Testing Lab WISE
24
53
Test-cases:
Condition:#include<stdio.h>(header file)
Test case:1
#include<stdio.h> false
Test case:2
Test case:3
Condition:
Int p;
Test case:1
Test case:2
Test case:3
Float p; Rejected
Analysis: Test case executed successfully
Condition:
Int q;
Test case:1
Test case:2
Condition:
P+q>100;
Test case:1
Test case:2
Test case:3
Test case:4
Condition:
Else
Test case:1
Test case:2
Test case:3
Condition:
p>50;
Test case:1
p>50 Accepted
Analysis: Test case executed successfully
Test case:2
Test case:3
Test case:4
Condition:
Else
Test case:1
Test case:2
Test cae:3
Exp No-10:-
Aim:
To identify and write the test cases for all du-paths and dc-paths for a given program.
Description:
Calculation of du-paths and dc-paths comes under "Data Flow Testing", where the focus is
mainly laid on variables. We use variables in a program for
1) Receiving Values
2) Referencing in Calculations
3) Setting other variables.
du-path calculation:
dc-path calculation:
Exp No-11:-
Aim:
To identify and write at least one test case for every program slice for a given program.
Description:
Program Slicing:
At first, slicing was only static, i.e., applied on the source code with no other information than
the source code. Bogdan Korel and Janusz Laski introduced dynamic slicing, which works on
a specific execution of the program (for a given execution trace). Other forms of slicing exist,
for instance path slicing.
Unlike dc and du paths in Data Flow Testing, " Program Slicing" or "Slice Based Testing" is
also efficient in removing data flow anamolies for the given program.
Let us consider a program, P for a program graph, G(P) for a given set of variables, V. Then
slice of V at statement n - S(V, n). Here, we exclude all non-executable statements.
1) Slice Composition
2) Relative complement of slices.
a) Static Slicing:
Based on the original definition of Weiser, informally, a static program slice S consists of all
statements in program P that may affect the value of variable v at some point p. The slice is
defined for a slicing criterion C=(x,V), where x is a statement in program P and V is a subset
of variables in P. A static slice includes all the statements that affect variable v for a set of all
possible inputs at the point of interest (i.e., at the statement x). Static slices are computed by
finding consecutive sets of indirectly relevant statements, according to data and control
dependencies.
int i;
int sum = 0;
int product = 1;
for(i = 1; i < N; ++i) {
sum = sum + i;
product = product * i;
}
write(sum);
write(product);
This new program is a valid slicing of the above program with respect to the criterion ( write
(sum) ,{sum}):
int i;
int sum = 0;
}
write(sum);
b) Dynamic Slicing:
Makes use of information about a particular execution of a program. A dynamic slice contains
all statements that actually affect the value of a variable at a program point for a particular
execution of the program rather than all statements that may have affected the value of a
variable at a program point for any arbitrary execution of the program.
An example to clarify the difference between static and dynamic slicing. Consider a small
piece of a program unit, in which there is an iteration block containing an if-else block. There
are a few statements in both the if and else blocks that have an effect on a variable. In the case
of static slicing, since the whole program unit is looked at irrespective of a particular
execution of the program, the affected statements in both blocks would be included in the
slice.
But, in the case of dynamic slicing we consider a particular execution of the program, wherein
the if block gets executed and the affected statements in the else block do not get executed. So,
that is why in this particular execution case, the dynamic slice would contain only the
#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;
11. a=b;
12. b=t;
13. }
14. printf (“%d %d”, a, b);
15 getch ();
}
1) Variable 'a':
2) Variable 'b':
3) Variable’t’:
Exp No-12:-
Aim:
To identify and write the test cases for relational coverage ,loop coverage and path testing.
Apply Mutuation testing and derive the mutuation score for each test case.
Description:
This metric reports whether boundary situations occur with relational operators (<, <=, >, >=).
The hypothesis is that boundary test cases find off-by-one mistakes and uses of the wrong
relational operators such as < instead of <=. For example, consider the following C code
fragment:
Eg: if (a < b)
Statement;
Relational operator coverage reports whether the situation a==b occurs. If a==b occurs and the
program behaves correctly, you can assume the relational operator is not suppose to be <=.
2) Loop Coverage
This metric reports whether you executed each loop body zero times, exactly once, and more
than once (consecutively). For do-while loops, loop coverage reports whether you executed the
body exactly once, and more than once.
The valuable aspect of this metric is determining whether while-loops and for-loops execute
more than once, information not reported by other metrics.
3) Path Coverage
This metric reports whether each of the possible paths in each function have been followed. A
path is a unique sequence of branches from the function entry to the exit.Also known as
predicate coverage. Predicate coverage views paths as possible combinations of logical
conditions.
Since loops introduce an unbounded number of paths, this metric considers only a limited
number of looping possibilities. A large number of variations of this metric exist to cope with
loops. Boundary-interior path testing considers two possibilities for loops: zero repetitions and
more than zero repetitions. For do-while loops, the two possibilities are one iteration and more
than one iteration.
Path coverage has the advantage of requiring very thorough testing. Path coverage has two
severe disadvantages. The first is that the number of paths is exponential to the number of
branches. For example, a function containing 10 if-statements has 1024 paths to test. Adding just
one more if-statement doubles the count to 2048. The second disadvantage is that many paths are
impossible to exercise due to relationships of data. For example, consider the following C code
fragment:
Eg: if (success)
statement1;
statement2;
If (success)
statement3;
Path coverage considers this fragment to contain 4 paths. In fact, only two are feasible:
success=false and success=true.
4) Mutation Testing:
Mutation testing is a technique that focuses on measuring the adequacy (quality) of test data (or
test cases). Here, we modify a program by introducing a single small change to the code.
Points to remember:
• A mutant is said to be killed when the execution of test case cause it to fail. The mutant is
considered to be dead
• A mutant is an equivalent to the given program if it always produce the same output as
the original program
• A mutant is called killable or stubborn, if the existing set of test cases is insufficient to
kill it
• A mutation score for a set of test cases is the percentage of non-equivalent mutants killed
by the test suite
i = 0;
n=4; //N-Number of nodes
present in the graph While
(i<n-1) do j = i + 1;
While (j<n) do
if A[i]<A[j] then swap
(A[i], A[j]); end do;
i=i+1;
end do
Write any one test case for each of relation coverage, loop coverage, path testing, mutuation
testing and calculate the mutuation score.