0% found this document useful (0 votes)
2 views16 pages

ST File

The document outlines practical exercises for a Software Testing course, including writing programs with intentional bugs, creating test cases, and reviewing code. It explains key concepts such as errors, faults, failures, verification, and validation, and provides examples of test cases for various scenarios. Additionally, it covers the Software Testing Life Cycle (STLC) and emphasizes the importance of structured testing and code reviews.

Uploaded by

8vtm52zmfy
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)
2 views16 pages

ST File

The document outlines practical exercises for a Software Testing course, including writing programs with intentional bugs, creating test cases, and reviewing code. It explains key concepts such as errors, faults, failures, verification, and validation, and provides examples of test cases for various scenarios. Additionally, it covers the Software Testing Life Cycle (STLC) and emphasizes the importance of structured testing and code reviews.

Uploaded by

8vtm52zmfy
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

Software Testing (BCA 204T) 2026

Practical 1
Aim: Write a small program in Python or Java with intentional bugs. Identify and classify
them as error, fault, or failure.

Python Code for Factorial:

num = int(input("Enter a number: "))


factorial = 1
if num < 0:
print("Factorial does not exist for negative numbers")
elif num == 0:
print("Factorial of 0 is 1")
else:
for i in range(1, num + 1):
factorial *= i
print("Factorial of", num, "is", factorial)

1. Error: An error is a mistake in a program that causes it to stop running or produce


incorrect results. It occurs when the code is written incorrectly or when something goes
wrong during execution.

Output:

Pushkar Sharma (50414202024) 1


Software Testing (BCA 204T) 2026

2. Fault: A fault is a defect or mistake in the source code of a program that can cause it
to produce incorrect results or fail during execution. In simple words, a fault is the
actual problem in the code that may lead to an error.

Output:

3. Failure: A failure is the incorrect or unexpected behavior of a program when it runs


due to a fault in the code. In simple words, failure happens when the system does not
perform as expected or produces wrong results during execution.

Output:

Pushkar Sharma (50414202024) 2


Software Testing (BCA 204T) 2026

Practical 2
Aim: Create a test case document for a calculator or login form and perform testing.

Code:-

def add(a, b):

return a + b

def subtract(a, b):

return a - b

def multiply(a, b):

return a * b

def divide(a, b):

if b == 0:

return "Cannot divide by zero"

return a / b

print("Simple Calculator")

print("1. Add")

print("2. Subtract")

print("3. Multiply")

print("4. Divide")

choice = int(input("Enter choice (1/2/3/4): "))

num1 = float(input("Enter first number: "))

num2 = float(input("Enter second number: "))

if choice == 1:

print("Result:", add(num1, num2))

elif choice == 2:

print("Result:", subtract(num1, num2))

Pushkar Sharma (50414202024) 3


Software Testing (BCA 204T) 2026

elif choice == 3:

print("Result:", multiply(num1, num2))

elif choice == 4:

print("Result:", divide(num1, num2))

else:

print("Invalid Choice")

Test Case:

A test case is a formal document that describes a specific condition or situation under which a
software application is tested. It contains a set of inputs, execution steps, and expected results
to verify whether the system behaves as intended. Test cases are designed based on software
requirements and help ensure that every feature of the application is properly tested.

Test cases are an essential part of the Software Testing Life Cycle (STLC). They provide a
structured approach to testing and help testers systematically check all functionalities of the
system. By executing test cases, testers can compare the actual results with the expected
results and identify any differences or defects.

Well-written test cases improve consistency and repeatability in testing. They allow different
testers to perform the same test and achieve similar results. Test cases also act as
documentation for future reference and maintenance.

Test cases help in:


 Identifying bugs and defects in the software
 Verifying that each requirement is correctly implemented
 Validating system behaviour under different conditions
 Reducing risk of failure after deployment
 Improving overall software quality and reliability

A good test case should be:


 Clear and easy to understand
 Simple and precise
 Reproducible
 Independent of other test cases

Each test case generally includes:


 Test Case ID
 Test Scenario
 Steps to Execute
 Preconditions/Prerequisites
 Test Data
 Expected Result
 Actual Result
 Status (Pass/Fail)

Pushkar Sharma (50414202024) 4


Software Testing (BCA 204T) 2026

Pushkar Sharma (50414202024) 5


Software Testing (BCA 204T) 2026

Test Cases Output:-

Pushkar Sharma (50414202024) 6


Software Testing (BCA 204T) 2026

Practical 3
Aim: Create a flowchart or diagram of STLC using online or offline drawing tools.

Theory:-

STLC (Software Testing Life Cycle):

 Software Testing Life Cycle (STLC) is a systematic and structured process followed
by the testing team to ensure the quality of software.
 It defines a sequence of testing activities that are performed from the initial stage of
understanding requirements to the final stage of test closure.
 STLC ensures that testing is carried out in a planned and organized manner.

Phases of STLC:

1. Requirement Analysis
In this phase, testers study the requirement documents carefully to understand the
system functionality. They identify testable requirements and determine the scope of
testing.
2. Test Planning
During this phase, the test strategy is defined. Testers decide the scope, objectives,
resources, schedule, and tools required for testing. A detailed test plan document is
prepared.
3. Test Case Development
In this phase, test cases and test data are designed and documented based on the
identified requirements. These test cases are reviewed to ensure completeness and
accuracy.
4. Test Environment Setup
The required hardware and software environment is prepared to execute the test cases.
Necessary configurations and installations are completed to ensure proper testing
conditions.
5. Test Execution
Test cases are executed in this phase. The actual results are compared with expected
results, and any defects identified are reported and tracked.
6. Test Cycle Closure
This is the final phase of STLC. Testing activities are evaluated, test summary reports
are prepared, defects are analysed, and lessons learned are documented for future
improvement.

Pushkar Sharma (50414202024) 7


Software Testing (BCA 204T) 2026

STLC Diagram:-

Pushkar Sharma (50414202024) 8


Software Testing (BCA 204T) 2026

Practical 4
Aim: Write test cases for form validation and explain how it satisfies verification and
validation.

Theory:

In software development, verification and validation are two fundamental concepts that play
a crucial role in ensuring software quality. Although the terms are often used together, they
differ in meaning and purpose.

Verification is the process of evaluating whether the software is being developed in


accordance with the specified requirements and design documents. It addresses the question:
“Are we building the product correctly?”.

Verification primarily involves reviewing documents, analysing design specifications, and


examining the source code without executing the program. Activities such as reviews,
inspections, and walkthroughs are part of the verification process. The main objective is to
ensure that each phase of development strictly follows the defined requirements and
standards.

On the other hand, validation is the process of determining whether the final software product
satisfies the user’s needs and expectations. It addresses the question: “Are we building the
right product?” Validation involves executing the software and performing testing to confirm
that it functions correctly in real-world scenarios. Various levels of testing, including system
testing and user acceptance testing, are included in the validation process.

Test Cases for Factorial Program:

Test Case 1
Test Case ID: TC01
Scenario: Valid Positive Number
Input: Number = 5
Expected Result: Factorial of 5 is 120
Actual Result: Factorial of 5 is 120
Status: Pass

Test Case 2
Test Case ID: TC02
Scenario: Input Zero
Input: Number = 0
Expected Result: Factorial of 0 is 1
Actual Result: Factorial of 0 is 1
Status: Pass

Pushkar Sharma (50414202024) 9


Software Testing (BCA 204T) 2026

Test Case 3
Test Case ID: TC03
Scenario: Negative Number
Input: Number = -3
Expected Result: Display message “Factorial does not exist for negative numbers”
Actual Result: Error message displayed
Status: Pass

Test Case 4
Test Case ID: TC04
Scenario: Large Positive Number
Input: Number = 7
Expected Result: Factorial of 7 is 5040
Actual Result: Factorial of 7 is 5040
Status: Pass

Test Case 5
Test Case ID: TC05
Scenario: Input as One
Input: Number = 1
Expected Result: Factorial of 1 is 1
Actual Result: Factorial of 1 is 1
Status: Pass

Test Case 6
Test Case ID: TC06
Scenario: Non-numeric Input
Input: Number = "abc"
Expected Result: Display message “Invalid input. Please enter a number”
Actual Result: Error message displayed
Status: Pass

Test Case 7
Test Case ID: TC07
Scenario: Very Large Number
Input: Number = 10
Expected Result: Factorial of 10 is 3628800
Actual Result: Factorial of 10 is 3628800
Status: Pass

Pushkar Sharma (50414202024) 10


Software Testing (BCA 204T) 2026

How These Test Cases Satisfy Verification and Validation:

Verification ensures that the factorial program is developed according to the specified
requirements and logic. The above test cases verify that the program correctly implements
rules such as handling positive numbers, zero, and negative numbers. By reviewing the
algorithm and ensuring that the factorial calculation is implemented properly, it confirms that
the program is built correctly.

Validation ensures that the factorial program works correctly when executed with different
inputs. By running the program with valid numbers, zero, negative values, and invalid inputs,
the actual results can be compared with the expected results. This confirms that the program
behaves correctly in real scenarios and produces accurate factorial results.

In conclusion, these test cases support verification by ensuring the factorial logic is
implemented properly and support validation by confirming correct program behaviour
during execution.

Pushkar Sharma (50414202024) 11


Software Testing (BCA 204T) 2026

Practical 5
Aim: Review a piece of code for logic, formatting, and style issues.

Theory:

Code review is a process in software testing where a program is examined to identify errors
in logic, formatting, structure, and coding standards. It helps in improving code quality,
readability, maintainability, and testability.

A good code review checks:


 Logical correctness
 Error handling
 Edge cases
 Proper indentation and formatting
 Meaningful variable and function names
 Following coding standards

Code:

To print the Fibonacci series:-

def fibonacci(n):

a=0

b=1

for i in range(n):

print(a, end=" ")

temp = a + b

a=b

b = temp

n = int(input("Enter the number of terms: "))

fibonacci(n)

Pushkar Sharma (50414202024) 12


Software Testing (BCA 204T) 2026

Output:

1. Logic Issues

 The logic for generating the Fibonacci series is correct.


 The program correctly updates the values of a and b in each iteration.
 However, if a negative number is entered, the loop will not execute properly, and no
validation is present.
 The function directly prints values instead of returning them, which limits flexibility.

2. Formatting Issues

 Indentation is correct (4 spaces).


 Proper spacing is maintained between statements.
 The structure of the function is clear and readable.
 No unnecessary blank lines are present.
 Overall, formatting follows standard Python conventions.

3. Style Issues

 Variable names a and b are short and not very descriptive. More meaningful names
like first and second would improve clarity.
 The variable temp is understandable but could be renamed to something more
descriptive like next_term.
 The loop variable i is not used inside the loop, so _ would be a better stylistic choice.
 The function prints output instead of returning values, which is not ideal for clean
coding practice.

Pushkar Sharma (50414202024) 13


Software Testing (BCA 204T) 2026

Practical 6
Aim: Write test cases for 3 numbers and find out the largest with different input
combinations without looking at the code (Using BVA).

Theory:

Test Case:

A test case is a set of conditions or variables used by a tester to determine whether a program
works correctly. It includes inputs, expected results, and the actual results obtained after
execution.

In black box testing, the tester does not look at the internal code of the program. Instead, the
program is tested by giving different inputs and checking whether the output is correct.

Two common testing techniques used here are Boundary Value Condition (BVC) and Worst
Case Testing.

Boundary Value Condition testing focuses on testing the program with values at the
boundaries of input ranges, such as minimum and maximum values. This helps identify errors
that often occur at extreme limits.

Worst Case Testing involves checking the system with extreme combinations of inputs. It
ensures that the program behaves correctly even in unusual or difficult situations.

Code:

a = int(input("Enter first number: "))

b = int(input("Enter second number: "))

c = int(input("Enter third number: "))

if a >= b and a >= c:

print("Largest number is", a)

elif b >= a and b >= c:

print("Largest number is", b)

else:

print("Largest number is", c)

Pushkar Sharma (50414202024) 14


Software Testing (BCA 204T) 2026

Test Cases Output:

Test Case 1
Test Case ID: TC01
Scenario: First number is largest
Input: A = 10, B = 5, C = 3
Expected Result: Largest number is 10
Actual Result: Largest number is 10
Status: Pass

Test Case 2
Test Case ID: TC02
Scenario: Second number is largest
Input: A = 4, B = 12, C = 7
Expected Result: Largest number is 12
Actual Result: Largest number is 12
Status: Pass

Test Case 3
Test Case ID: TC03
Scenario: Third number is largest
Input: A = 6, B = 9, C = 15
Expected Result: Largest number is 15
Actual Result: Largest number is 15
Status: Pass

Test Case 4
Test Case ID: TC04
Scenario: All numbers equal
Input: A = 5, B = 5, C = 5
Expected Result: All numbers are equal
Actual Result: All numbers are equal
Status: Pass

Test Case 5
Test Case ID: TC05
Scenario: Boundary Value Condition (Minimum Values)
Input: A = 0, B = 0, C = 1
Expected Result: Largest number is 1
Actual Result: Largest number is 1
Status: Pass

Test Case 6
Test Case ID: TC06
Scenario: Boundary Value Condition (Maximum Values)
Input: A = 100, B = 99, C = 98
Expected Result: Largest number is 100
Actual Result: Largest number is 100
Status: Pass

Pushkar Sharma (50414202024) 15


Software Testing (BCA 204T) 2026

Test Case 7
Test Case ID: TC07
Scenario: Worst Case Testing (Negative numbers)
Input: A = -5, B = -2, C = -9
Expected Result: Largest number is -2
Actual Result: Largest number is -2
Status: Pass

Test Case 8
Test Case ID: TC08
Scenario: Worst Case Testing (Mixed values)
Input: A = -10, B = 50, C = 0
Expected Result: Largest number is 50
Actual Result: Largest number is 50
Status: Pass

Pushkar Sharma (50414202024) 16

You might also like