Let's Review
Types of Errors
Categorize given codes to correct errors (10 min)
x = 10 / 0 print("Hello, World" arr = [1, 2, 3, 4, 5] int x = 10
for i in range(1,
len(arr)):
print(arr[i])
def int *p = NULL; int x; arr = [1, 2, 3]
calculate_area(length *p = 10; x = "abc"; print(arr[5])
, width):
return length +
width
age = def my_function(): def check_positive(x): iff x > 10:
int(input("Enter your print("Hello") if x < 0: print("x is greater
age: ")) print("x is than 10")
positive")
x = int("hello") def find_max(arr): file = open def
max_val = 0 ("nonexistent_file.txt" recursive_function():
for num in arr: if , "r") return
num > max_val: recursive_function()
max_val = num recursive_function()
return max_val
Syntax errors with description
int x = 10 // Missing semicolon causes syntax error
print("Hello, World" # Missing closing parenthesis causes syntax
error
iff x > 10: # 'iff' instead of 'if' causes a syntax error
print("x is greater than 10")
def my_function():
print("Hello") # Misaligned indentation causes a syntax error
name = "John # Missing closing quote causes a syntax error
int x; // Correct declaration
x = "abc"; // Syntax error due to wrong type assignment in C
Runtime errors with description
x = 10 / 0 # Raises a ZeroDivisionError at runtime
int *p = NULL;
*p = 10; // Causes a segmentation fault (runtime error) due to null
pointer access
arr = [1, 2, 3]
print(arr[5]) # Raises an IndexError at runtime
arr = [1, 2, 3]
print(arr[5]) # Raises an IndexError at runtime
x = int("hello") # Raises a ValueError at runtime
file = open("nonexistent_file.txt", "r") # Raises a
FileNotFoundError at runtime
def recursive_function():
return recursive_function() # Infinite recursion causes a stack
overflow
Logic errors with description
def calculate_area(length, width):
return length + width # Logic error: should be multiplication,
not addition
# Expected output for length = 5, width = 3 is 15 (5 * 3), but
result is 8 (5 + 3)
print(calculate_area(5, 3))
def check_positive(x):
if x < 0: # Logic error: should be "x >= 0" to check for positive
numbers
print("x is positive")
check_positive(5) # Logic error: Prints nothing, but 5 is positive
Logic errors with description
arr = [1, 2, 3, 4, 5]
for i in range(1, len(arr)): # Logic error: Starts from index 1,
misses the first element
print(arr[i])
# Expected output: 1 2 3 4 5, but the logic error produces: 2 3 4 5
def sum_numbers(arr):
total = 0
for num in arr:
total = 0 # Logic error: resetting the total in each iteration
total += num
return total
print(sum_numbers([1, 2, 3])) # Logic error: Always returns the
last number, 3
Logic errors with description
def find_max(arr):
max_val = 0 # Logic error: Assumes max value is 0, which is
incorrect for negative numbers
for num in arr:
if num > max_val:
max_val = num
return max_val
# Expected output for arr = [-5, -2, -9] is -2, but the logic error
returns 0
print(find_max([-5, -2, -9]))
Software
Testing
Learning various types of
Testing
Testing is the process of
evaluating and verifying
that a software application
or system functions as
intended. It involves
Testing in executing the software with
the goal of finding defects
Software (bugs) or inconsistencies in
behavior. Testing ensures
Development that the software meets the
specified requirements,
works correctly, and
satisfies user expectations
before it is released to
production.
The
Purpos
e&
Types
of
Testing
Detectin Detecting defects: Identifying bugs or errors in
g the software.
Ensurin Ensuring functionality: Verifying that the
The key goals
software behaves as expected under various
g conditions.
of software Validating requirements: Ensuring that the
Validatin
testing g
software meets the initial business and
technical requirements.
Improvi Improving quality: Enhancing the overall
ng quality and reliability of the software.
Software testing can be categorized into
Types of Software
different types based on the purpose,
method, and level at which the testing is
done.
1. Manual Testing
• Testing the software manually without the
use of automated tools. The tester
manually executes the test cases and
checks the application’s behavior.
2. Automated Testing
Testing
• Using automated tools and scripts to
perform tests. This is more efficient for
repetitive tests and large-scale projects.
Example: Using Selenium for browser
automation.
3. Unit Testing
• Testing individual components or
Based on Testing
functions of the software in isolation to
ensure that each unit works correctly.
Example: Testing a specific function in
a class or a method in Python.
Tools: JUnit (Java), PyTest (Python),
NUnit (.NET)
4. Integration Testing
• Testing how multiple components or units
Levels
work together. Integration tests ensure
that different modules of the system
interact correctly.
Example: Testing a user login function
with both the user interface and backend
API.
Tools: Postman, JUnit, TestNG
Testing the entire system as a whole to
ensure that it meets the specified
requirements. It checks the software in an
Based on Testing environment that simulates real-world
usage.
Example: Testing a complete e-commerce
application with all functionalities (login,
shopping cart, payment, etc.).
Tools: Selenium, QTP (QuickTest
Professional)
Levels
6. Acceptance Testing
Testing the system to check if it meets the
business requirements and is ready for
delivery. It is often conducted by end-
users or clients.
Example: A client tests a new feature to
make sure it works as expected before the
Based on Testing 7. White-Box Testing
• Testing based on knowledge of the
internal structure of the application (e.g.,
code, algorithms).
• Testers have access to the codebase and
test logic paths, branches, and internal
Methods
components.
Example: Testing all possible loops and
conditions in a function.
Tools: NUnit, JUnit
Based on Testing 8. Black-Box Testing
• Testing without knowledge of the internal
structure of the software.
• Testers focus on inputs and expected
outputs, treating the application as a
"black box."
Methods
Example: Testing a login form by entering
different username-password combinations
without knowing how the backend is
implemented.
Tools: Selenium, TestRail
Based on Testing
9. Gray-Box Testing
• A hybrid testing method that combines
elements of both white-box and black-box
testing.
• Testers have partial knowledge of the
internal structure but test primarily from
an external perspective.
Methods
Example: Knowing how a database query
works and testing the front-end with that
knowledge.
In the next slide types of Testing based
on Objectives are given.
Give each group 2 types of testing to
study and research.
Group work
Each group should make two-slide
presentation.
It should only take 2 minutes of
researching.
And 2 minutes of presentation.
Based on Testing Group
1
Functional
Testing
Non-Functional
Testing
Group Performance
Load Testing
2 Testing
Objectives
Group Security
Stress Testing
3 Testing
Group Usability Regression
4 Testing Testing
Group
Sanity Testing Smoke Testing
5