Software Testing
B.Tech-IT, Sem V
Prepared By:
Kathan Balar (202503103530001)
Submitted to:
Ms. Vidhi Patel
Faculty of AMTICS
(Uka Tarsadia University)
Software Testing Enrollment :-20250310353001
PRACTICAL-1
Aim:- Case study on the significance of software architectures.
Code:
Test Case ID Test Case Expected Actual Result
Description Output Output
TC-01 Check with True True Pass
positive even
number - 4
TC-02 Check with False False Pass
positive odd
number – 5
TC-03 Check with zero True True Pass
-0
TC-04 Check with True True Pass
negative even
number – (-6)
TC-05 Check with False False Pass
negative odd
number – (-7)
1
Software Testing Enrollment :-20250310353001
PRACTICAL-2
Aim:- To understand and apply quality attributes of software architectures.
Code:
Test Case ID Test Case Expected Actual Result
Description Output Output
TC-01 Marks below Failed Failed Pass
fail threshold-
25
TC-02 Pass
Marks exactly Passed Passed
at fail
threshold
- 30
TC-03 Marks in Pass
Passed Passed
normal pass
range – 50
TC-04 Marks in Passed with Passed with Pass
distinction distinction distinction
range – 80
TC-05 Marks exactly Pass
Passed Passed
at distinction
limit - 75
2
Software Testing Enrollment :-20250310353001
PRACTICAL-3
Aim:- To conduct sprint planning, create user stories, and track progress using
Code:
Test Case ID Test Case Expected Actual Result
Description Output Output
TC-01 6 6 Pass
Factorial of a
small number
- 3
TC-02 Factorial of 1 1 1 Pass
(base case)
TC-03 Factorial of 0 1 Error Fail
(should return
1)
TC-04 Factorial of Error/Invalid Error Fail
negative
number – (-5)
TC-05 120 120 Pass
Factorial of 5
3
Software Testing Enrollment :-20250310353001
Fail cases (TC03, TC04):
The function should include a condition for x == 0 (since 0! = 1).
Negative inputs should raise a ValueError or return a message.
4
Software Testing Enrollment :-20250310353001
PRACTICAL-4
Aim:- Given the function to check if the number is prime or not (in Python).
Code:
Test Case ID Test Case Expected Actual Result
Description Output Output
TC-01 Prime number – Yes, 7 is Prime Pass
Yes, 7 is Prime
7
TC-02 Non-prime No, 10 is not a No, 10 is not a Pass
number – 10 Prime Prime
TC-03 Smallest prime Pass
Yes, 2 is Prime Yes, 2 is Prime
number – 2
TC-04 Input is 1 (not Yes, 1 is Prime Fail
No, 1 is not a
prime)
Prime
TC-05 Input is 0 (not No, 0 is not a Yes, 0 is Prime Fail
prime) Prime
Fail cases (TC-04):- Prime check incorrect for 1; should return False.
Fail cases (TC-05):- No handling for values < 2; gives wrong result.
5
Software Testing Enrollment :-20250310353001
PRACTICAL-5
Aim:- Python Program for How to check if a given number is Fibonacci
number?
Code:
Test Case ID Test Case Expected Actual Result
Description Output Output
TC-01 Fibonacci 5 is a Fibonacci Pass
5 is a
number in the Number
Fibonacci
sequence - 3
Number
TC-02 Non-Fibonacci 4 is not 4 is not Pass
number Fibonacci Fibonacci
Number Number
- 4
TC-03 Fibonacci 1 is a Fibonacci 1 is a Fibonacci Pass
number (start of Number Number
range) - 1
TC-04 Fibonacci 8 is a Fibonacci 8 is a Fibonacci Pass
number (larger) Number Number
–8
TC-05 Edge case: not 10 is not 10 is not Pass
Fibonacci -10 Fibonacci Fibonacci
Number Number
6
Software Testing Enrollment :-20250310353001
PRACTICAL-6
Aim:- Create BVA test cases for the triangle. The output of the program maybe:
Equilateral, Isosceles, Scalene, or “NOT -A-TRIANGLE”.
Valid Triangle Conditions:- (i) a + b > c (ii) b + c > a (iii) a + c > b
For BVA, we assume a range like:- Minimum value: 1 Maximum value: 100
Possible Outputs:- (i) Equilateral: All sides are equal (a = b = c)
(ii) Isosceles: Exactly two sides are equal
(iii) Scalene: All sides are different and satisfy triangle inequality
(iv) NOT-A-TRIANGLE: The sides don't form a valid triangle
BVA Test Cases Table
Test Case a b c Reason / Expected
Type Output
TC-1 1 1 1 Min Equilateral
boundary,
valid
TC-2 2 2 3 Near lower Isosceles
boundary
TC-3 2 3 4 Lower mid- Scalene
range
TC-4 100 100 100 Max Equilateral
boundary,
valid
TC-5 99 99 1 Violates NOT-A-
triangle rule TRIANGLE
TC-6 1 2 3 Edge of NOT-A-
triangle TRIANGLE
inequality
TC-7 50 50 100 Violates NOT-A-
triangle rule TRIANGLE
TC-8 100 99 98 Near upper Scalene
boundary
TC-9 0 50 50 Below lower NOT-A-
boundary TRIANGLE
TC-10 101 50 50 Above upper NOT-A-
boundary TRIANGLE
TC-11 100 100 1 Almost a NOT-A-
line TRIANGLE
TC-12 3 3 5 Valid Isosceles
isosceles
TC-13 10 20 30 Boundary NOT-A-
triangle rule TRIANGLE
7
Software Testing Enrollment :-20250310353001
TC-14 33 33 33 Mid-range Equilateral
equilateral
TC-15 50 70 80 Valid scalene Scalene
BVA Equation Used:-
Test values = {min − 1, min, min + 1, max − 1, max, max + 1}
8
Software Testing Enrollment :-20250310353001
PRACTICAL-7
Aim:- Apply BVA to a user registration form where the age field must be
Between 18 and 99 years old.
Age Field Specification:- Minimum valid age: 18, Maximum valid age: 99
BVA Equation Used:-
If input range = [min, max],
Then BVA test values = {min−1, min, min+1, max−1, max, max+1}
Code:-
class Employee:
def __init__(self, age):
self.age = age
# Validation function
def validate_age(self):
if self.age < 18 or self.age > 99:
return "Rejected"
else:
return "Accepted
if __name__ == "__main__":
# BVA test values
test_ages = [17, 18, 19, 98, 99, 100]
# Print table header
print(f"{'TestCase':<10}{'Age Input':<12}{'Type':<25}{'Expected Result'}")
print("-" * 70)
# Run test cases
for i, age in enumerate(test_ages, start=1):
emp = Employee(age)
# Determine type of test
if age == 17:
type_desc = "Just below min (invalid)"
9
Software Testing Enrollment :-20250310353001
elif age == 18:
type_desc = "Minimum boundary (valid)"
elif age == 19:
type_desc = "Just above min"
elif age == 98:
type_desc = "Just below max"
elif age == 99:
type_desc = "Maximum boundary (valid)"
elif age == 100:
type_desc = "Just above max (invalid)"
else:
type_desc = "Other"
# Print test case row
print(f"{'TC-'+str(i):<10}{age:<12}{type_desc:<25}{emp.validate_age()}")
Test Case Age Input Type Expected Result
TC-1 17 Just below min Rejected
(invalid)
TC-2 18 Minimum boundary Accepted
(valid)
TC-3 19 Just above min Accepted
TC-4 98 Just below max Accepted
TC-5 99 Maximum boundary Accepted
(valid)
TC-6 100 Just above max Rejected
(invalid)
10
Software Testing Enrollment :-20250310353001
PRACTICAL-8
Aim:- Suppose you are working on an Employee Management System with a
class Employee that includes an age attribute. The age attribute that
includes an age attribute. The age attribute must be between 18 and 65.
We will create test cases for this class using BVA principles.
Problem Statement:- Employee class has an attribute age.
Valid range: 18 ≤ age ≤ 65.
Invalid if age < 18 or age > 65.
BVA Equation Used:-
If input range = [min, max],
Then test values = {min−1, min, min+1, max−1, max, max+1}
Code:-
class Employee:
def __init__(self, age):
self.age = age
# Validation function
def validate_age(self):
if self.age < 18 or self.age > 65:
return "Rejected"
else:
return "Accepted"
if __name__ == "__main__":
# BVA test values
test_ages = [17, 18, 19, 64, 65, 66]
# Print table header
print(f"{'TestCase':<10}{'Age':<10}{'Type':<20}{'Expected Result'}")
print("-" * 60)
# Run test cases
11
Software Testing Enrollment :-20250310353001
for i, age in enumerate(test_ages, start=1):
emp = Employee(age)
# Determine type of test
if age == 17:
type_desc = "Below Min"
elif age == 18:
type_desc = "Min Boundary"
elif age == 19:
type_desc = "Just Above Min"
elif age == 64:
type_desc = "Just Below Max"
elif age == 65:
type_desc = "Max Boundary"
elif age == 66:
type_desc = "Above Max"
else:
type_desc = "Other"
# Print test case row
print(f"{'TC'+str(i):<10}{age:<10}{type_desc:<20}{emp.validate_age()}")
Test Case Age Type Expected Result
TC-1 17 Below Min Rejected
TC-2 18 Min Boundary Accepted
TC-3 19 Just Above Min Accepted
TC-4 64 Just Below Max Accepted
TC-5 65 Max Boundary Accepted
TC-6 66 Above Max Rejected
12
Software Testing Enrollment :-20250310353001
PRACTICAL-9
Aim:- Let us consider an example of grading the students in an academic
institution. The grading is done according to the following rules:
Marks -> obtained Grade: 80–100 Distinction,
60–79 First division, 50–59 Second division , 40–49 Third division
0–39 Fail, Generate test cases using the equivalence class testing
technique.
BVA Equation Used:-
If input range = [min, max] divided into partitions,
Then pick 1 valid representative value from each class,
And pick 1 invalid value from outside the domain.
Code:-
# Function to get grade based on marks
def get_grade(marks):
if marks < 0 or marks > 100:
return "Invalid Input"
elif marks >= 80:
return "Distinction"
elif marks >= 60:
return "First Division"
elif marks >= 50:
return "Second Division"
elif marks >= 40:
return "Third Division"
else:
return "Fail"
13
Software Testing Enrollment :-20250310353001
if __name__ == "__main__":
# Representative test cases from equivalence classes
test_marks = [85, 70, 55, 45, 30, -5, 105]
# Print header
print(f"{'TestCase':<10}{'Marks':<10}{'Equivalence Class':<25}{'Expected Grade'}")
print("-" * 70)
# Iterate and print results
for i, marks in enumerate(test_marks, start=1):
# Determine equivalence class
if 80 <= marks <= 100:
eq_class = "80–100 (Distinction)"
elif 60 <= marks <= 79:
eq_class = "60–79 (First Division)"
elif 50 <= marks <= 59:
eq_class = "50–59 (Second Division)"
elif 40 <= marks <= 49:
eq_class = "40–49 (Third Division)"
elif 0 <= marks <= 39:
eq_class = "0–39 (Fail)"
elif marks < 0:
eq_class = "Invalid (<0)"
else:
eq_class = "Invalid (>100)"
# Print result row
print(f"{'TC'+str(i):<10}{marks:<10}{eq_class:<25}{get_grade(marks)}")
14
Software Testing Enrollment :-20250310353001
Test Case Marks Equivalence Class Expected Grade
TC-1 85 Distinction
80–100 (Distinction)
TC-2 70 60–79 (First Division) First Division
TC-3 55 50–59 (Second Second Division
Division)
TC-4 45 40–49 (Third Third Division
Division)
TC-5 30 0–39 (Fail) Fail
TC-6 -5 Invalid (< 0)
Invalid Input
TC-7 105 Invalid (> 100) Invalid Input
15
Software Testing Enrollment :-20250310353001
PRACTICAL-10
Aim:- Write a program for the determination of next date in a
calendar. Its input is a triple of day, month, and year with the
following range: 1 ≤ month ≤ 12, 1 ≤ day ≤ 31, 1900 ≤ year ≤ 2025
The possible outputs would be next date or invalid date. Design
boundary value, robust, and worst test cases for
this program.
BVA Equation Used:-
If input range = [min, max],
Then test values = {min−1, min, min+1, max−1, max, max+1}
Code:-
def is_leap(year):
return (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0)
def days_in_month(month, year):
if month == 2:
return 29 if is_leap(year) else 28
if month in [4,6,9,11]:
return 30
return 3
def is_valid(d,m,y):
if m < 1 or m > 12 or d < 1 or d > days_in_month(m,y):
return False
return True
def next_date(d,m,y):
if not is_valid(d,m,y):
return "Invalid date"
d += 1
if d > days_in_month(m,y):
d=1
16
Software Testing Enrollment :-20250310353001
m += 1
if m > 12:
m=1
y += 1
return f"{d}/{m}/{y}"
# Test cases (BVA + Robust + Worst)
test_cases = [
(1,1,2024), (31,1,2024), (28,2,2023), (29,2,2024), (31,12,2024),
(0,5,2024), (32,1,2024), (15,0,2024), (20,13,2024),
(0,0,1899), (32,13,2101), (31,12,2100)
print(f"{'TC':<5}{'Input(d,m,y)':<15}Output")
print("-"*40)
for i,(d,m,y) in enumerate(test_cases, start=1):
print(f"TC{i:<3}{(str(d)+','+str(m)+','+str(y)):<15}{next_date(d,m,y)}")
17
Software Testing Enrollment :-20250310353001
Boundary Value Test Cases (Normal BVA)
Test Case Input (d,m,y) Reason Expected Output
TC-1 1, 1, 2024 First valid day/month 2/1/2024
TC-2 31, 1, 2024 Last day of Jan 1/2/2024
TC-3 28, 2, 2023 Non-leap Feb 1/3/2023
TC-4 29, 2, 2024 Leap year Feb 1/3/2024
TC-5 31, 12, 2024 Year-end boundary 1/1/2025
Robust BVA Test Cases (Outside Range)
Test Case Input (d,m,y) Reason Expected Output
TC-6 0, 5, 2024 Invalid date
Invalid day (below
min)
TC-7 32, 1, 2024 Invalid day (above Invalid date
max)
TC-8 15, 0, 2024 Invalid date
Invalid month (below
min)
TC-9 20, 13, 2024 Invalid month (above Invalid date
max)
Worst-case BVA (Combining multiple variables)
Test Case Input (d,m,y) Reason Expected Output
TC-10 All below min
0, 0, 1899 Invalid date
TC-11 All above max Invalid date
32, 13, 2101
TC-12 31, 12, 2100
Max boundary valid 1/1/2101
18
Software Testing Enrollment :-20250310353001
PRACTICAL-11
Aim:- Design and implement a login validation feature for a web application
using the Cause-Effect Graphing Technique to ensure comprehensive
test coverage.
Code:-
def login(username, password, user_db):
if not username or not password:
return "Username/Password required"
if username not in user_db:
return "Invalid Username"
if user_db[username] != password:
return "Invalid Password"
return "Login Successful"
# Mock user database
user_db = {"user": "correct"}
# Test cases derived from Cause-Effect Graphing
test_cases = [
("", "", "Username/Password required"),
("", "abc", "Username/Password required"),
("user", "", "Username/Password required"),
("nouser", "pwd", "Invalid Username"),
("user", "wrong", "Invalid Password"),
("user", "correct", "Login Successful"),
print(f"{'TC':<5}{'Username':<12}{'Password':<12}{'Expected'}")
print("-"*50)
for i, (u, p, expected) in enumerate(test_cases, start=1):
result = login(u, p, user_db)
19
Software Testing Enrollment :-20250310353001
print(f"TC{i:<3}{u:<12}{p:<12}{result}")
The cause–effect graph:-
Test Case Username Password Exists? Correct Expected Result
Password?
TC-1 - - "Username/Password
"" ""
required"
TC-2 - - "Username/Password
"" "abc"
required"
TC-3 "user" - - "Username/Password
""
required"
TC-4 "nouser" No -
"pwd" "Invalid Username"
TC-5 "user" Yes No
"wrong" "Invalid Password"
TC-6 "user" "correct" Yes Yes
"Login Successful"
20
Software Testing Enrollment :-20250310353001
PRACTICAL-12
Aim:- Utilize a Kiviat Chart to visually compare the level of internet diffusion
Across multiple countries based on various factors.
Code:-
import matplotlib.pyplot as plt
import numpy as np
# Sample data: Internet diffusion factors across multiple countries
factors = ["Internet Penetration (%)", "Mobile Broadband (%)",
"Fixed Broadband (%)", "E-Government Index", "Online Services (%)"]
countries = ["USA", "India", "Germany", "Brazil", "Japan"]
# Example normalized values (0-100 scale)
data = {
"USA": [95, 90, 85, 92, 94],
"India": [55, 70, 30, 60, 65],
"Germany": [93, 88, 80, 90, 91],
"Brazil": [75, 80, 50, 70, 72],
"Japan": [94, 89, 87, 91, 92]}
# Number of variables
num_vars = len(factors)
# Compute angle for each factor axis
angles = np.linspace(0, 2 * np.pi, num_vars, endpoint=False).tolist()
angles += angles[:1] # Complete the loop
# Plot Kiviat Chart
fig, ax = plt.subplots(figsize=(8, 8), subplot_kw=dict(polar=True))
# Draw one axis per factor and add labels
plt.xticks(angles[:-1], factors, fontsize=10)
# Draw y-labels (radial axis)
ax.set_rlabel_position(30)
plt.yticks([20, 40, 60, 80, 100], ["20", "40", "60", "80", "100"], color="grey", size=8)
21
Software Testing Enrollment :-20250310353001
plt.ylim(0, 100)
# Plot each country
for country, values in data.items():
stats = values + values[:1] # Repeat first value to close the circle
ax.plot(angles, stats, label=country, linewidth=2)
ax.fill(angles, stats, alpha=0.25)
# Add legend
plt.legend(loc="upper right", bbox_to_anchor=(1.2, 1.1))
plt.title("Kiviat Chart: Internet Diffusion Across Countries", size=14, pad=20)
plt.show()
Kiviat Chart (Radar Chart):-
22