SE 9th
SE 9th
SE 9th
PART A
Experiment No.09
A.1 Aim:
Perform white box (Basic Path Testing) or black box testing on any one function
developed (code) of selected mini project and develop the test cases for same.
A.2 Prerequisite:
Knowledge about software testing and types of testing.
A.3 Outcome:
After successful completion of this experiment students will be able to differentiate
between white and black box testing and able to perform white box testing.
A.4 Theory:
Software Testing
Software testing is a method to check whether the actual software product matches expected
requirements and to ensure that software product is Defect free. It involves execution of
software/system components using manual or automated tools to evaluate one or more
properties of interest. The purpose of software testing is to identify errors, gaps or missing
requirements in contrast to actual requirements.
Software testing is defined as an activity to check whether the actual results match the
expected results and to ensure that the software system is Defect free.
Testing is important because software bugs could be expensive or even dangerous.
The important are reasons for using software testing are: cost-effective, security, product
quality, and customer satisfaction.
Typically Testing is classified into three categories functional testing, non-functional
testing or performance testing, and maintenance.
The important strategies in software engineering are: unit testing, integration testing,
system testing , validation testing (User acceptance testing).
Functional Testing
Non-Functional Testing or Performance Testing
Maintenance (Regression and Maintenance)
Integration testing: It focuses on the construction and design of the software. You need to
see that the integrated units are working without errors or not.
System testing: In this method, your software is compiled as a whole and then tested as a
whole. This testing strategy checks the functionality, security, portability, amongst others.
Functional Testing
FUNCTIONAL TESTING is a type of software testing that validates the software system
against the functional requirements/specifications. The purpose of Functional tests
is to test each function of the software application, by providing appropriate input,
verifying the output against the Functional requirements.
Functional testing mainly involves black box testing and it is not concerned about the
source code of the application. This testing checks User Interface, APIs, Database,
Security, Client/Server communication and other functionality of the Application under
Test. The testing can be done either manually or using automation.
The prime objective of Functional testing is checking the functionalities of the software
system. It mainly concentrates on -
White-Box Testing
White-box testing:
Knowing the internal workings of a product, test that all internal operations are
performed according to specifications and all internal components have been
exercised.
Types of White Box Testing:
Introduction:
Path testing is a structural testing method that involves using the source code of a
program in order to find every possible executable path. It helps to determine all faults
lying within a piece of code. This method is designed to execute all or selected path through
a computer program.
Any software program includes multiple entry and exit points. Testing each of these
points is a challenging as well as time-consuming. In order to reduce the redundant
tests and to achieve maximum test coverage, basis path testing is used.
It is White-box testing technique proposed by Tom McCabe. Enables the test case designer to
derive a logical complexity of a procedural design(system). And then use this measure to
define basis set of execution paths developer uses this. Test cases derived to exercise the basis
set are guaranteed to execute every statement in the program at least one time during testing.
Basis Path Testing in software engineering is a White Box Testing method in which test cases are
defined based on flows or logical paths that can be taken through the program.
Here we will take a simple example, to get a better idea what is basis path testing include
In the above example, we can see there are few conditional statements that is executed
depending on what condition it suffice. Here there are 3 paths or condition that needs to be
tested to get the output,
Path 1: 1,2,3,5,6, 7
Path 2: 1,2,4,5,6, 7
Path 3: 1, 6, 7
Draw a control graph (flow graph) (to determine different program paths)
Calculate Cyclomatic complexity (metrics to determine the number of independent paths)
Find a basis set of paths
Generate test cases to exercise each path
Flow Graph Notation:
A circle in a graph represents a node, which stands for a sequence of one or more
procedural statements.
A node containing a simple conditional expression is referred to as a predicate node.
Each compound condition in a conditional expression containing one or more
Boolean operators (e.g., and, or) is represented by a separate predicate node.
A predicate node has two edges leading out from it (True and False).
An edge, or a link, is a an arrow representing flow of control in a specific direction.
An edge must start and terminate at a node.
An edge does not intersect or cross over another edge.
Areas bounded by a set of edges and nodes are called regions.
When counting regions, include the area outside the graph as a region too.
Figure 7.1: Procedural Design using Figure 7.2: Flow Graph Notation of given
Flowchart Flowchart
----------------------------------------------------------------------------------------------------------------
Example 2: Consider the given program that checks if a number is prime or not. For
the following program:
int main()
1 int n, index;
2 cout << "Enter a number: " <> n;
3 index = 2;
5 {
6 if (n % index == 0)
7 {
9 break;
10 }
11 index++;
12 }
13 if (index == n)
15 } // end main
Method-1:
V(G) = e - n + 2
In the above control flow graph,
where, e = 10, n = 8 and p = 1
Therefore,
Cy-clomatic Complexity V(G)
= 10 - 8 + 2
=4
Method-2:
V(G) = P+1
In the above control flow graph,
where, P = 3 (Node B, C and F)
Therefore,
Cyclomatic Complexity V(G)
=3+1
=4
Method-3:
2) Independent Paths:
Path 1 : A - B - F - G - H
Path 2 : A - B - F - H
Path 3 : A - B - C - E - B - F - G - H
Path 4 : A - B - C - D - F - H
Note:
3) Test cases:
To derive test cases, we have to use the independent paths obtained previously. To design a
test case, provide input to the program such that each independent path is executed.
For the given program, the following test cases will be obtained:
Test case
ID Input Number Output Independent path covered
Test case
ID Input Number Output Independent Path covered
1 1 No output A-B-F-H
(Students must submit the soft copy as per following segments within two hours of the
practical. The soft copy must be uploaded on the Blackboard or emailed to the concerned lab in
charge faculties at the end of the practical in case the there is no Black board access available)
Grade :
(Students are expected to understand the selected topic of basic path testing and complete the
following)
1. List out one code of selected mini project (any one function or program) and draw
flow graph notation of same .(write code below that draw flow graph)
import cv2
import numpy as np
import face_recognition
import os
from datetime import datetime from
tkinter import filedialog import tkinter as tk
# Initialize a Tkinter window to ask the user for the image file root =
tk.Tk()
root.withdraw() # Hide the main Tkinter window
def markAttendance(name):
with open('Attendance.csv', 'r+') as f: myDataList = f.readlines()
nameList = []
for line in myDataList: entry =
line.split(',')
nameList.append(entry[0])
now = datetime.now()
dtString = now.strftime('%H:%M:%S')
matchIndex = np.argmin(faceDis)
if matches[matchIndex]:
name = classNames[matchIndex].upper() y1, x2,
y2, x1 = faceLoc
y1, x2, y2, x1 = y1 * 4, x2 * 4, y2 * 4, x1 * 4
cv2.rectangle(img, (x1, y1), (x2, y2),
(0, 255, 0), 2)
# cv2.rectangle(img, (x1, y2 - 35), (x2, y2), (0, 255, 0),
cv2.FILLED)
cv2.putText(img, name, (x1 + 6, y2 - 6),
cv2.FONT_HERSHEY_COMPLEX, 1, (255, 255, 255), 2)
markAttendance(name)
B.2: Questions
Clear-box testing,
Functional testing,
Also Known As Glass-box testing,
Behavioral testing.
Transparent-box testing.
Focuses on user
Effective at finding perspective, simulates
Advantages logical errors, missing real-world usage, and
code paths, and identifies functional
security defects.
vulnerabilities.
Involves evaluating if
Involves validating if the the software meets
Validation Criteria software meets functional quality standards,
specifications. performance
benchmarks, and user
expectations.
Functionality Response time, throughput,
Typical Metrics completeness, correctness, error rates, security
reliability. vulnerabilities.
B.3 Conclusion: (Students must write the conclusion as per the attainment of individual
outcome listed above and learning/observation)
White box testing is focused on the internal structures and code of a software application,
whereas black box testing assesses the functionality and behavior of the application from
an external perspective.