COMSATS University Islamabad, Abbottabad
Campus
Department of Computer Science
FALL 2024
Lab Assignment 1
Name: Mian Habib Jan Reg No: Sp21-Bse-042
Name: Muhammad Ibrahim Reg No: Sp21-Bse-096
Name: Sayed Mujtaba Reg No: Sp21-Bse-091
Instructor: Mam Mehwish Sabir
Subject: Software Testing
QUESTION 1
Demonstrates the difference in Error, Fault and Failure.
pre: param is an integer.
post: returns the product of the param multiplied by 2.
1. int double (int param) {
2. int result;
3. result = param * param;
4. return result;
5. }
Solution:
Error:
Human mistake: The programmer mistakenly multiplied the parameter by itself instead of
multiplying it by 2.
Location: Line 3: result = param * param;
Fault:
Incorrect implementation: The code contains a defect that causes it to produce incorrect results.
Location: Line 3: result = param * param;
Failure:
Deviation from expected behavior: When the function is called with a non-zero input, it returns
an incorrect result, which is different from the specified postcondition.
Impact: The function's intended purpose is not fulfilled.
Correct java code:
int double (int param) {
int result = param * 2;
return result;
}
Explanation:
Error: The human error of multiplying by the parameter itself was identified.
Fault: The incorrect implementation of the multiplication operation was corrected.
Failure: The incorrect behavior of the function, which was caused by the fault, is now resolved.
QUESTION 2
Consider Cu-online system Identify, document, and report defects found
during testing
1. Identify Defects
In university online system, some of the main areas that could be tested include:
Functional Areas:
User Authentication: Login/logout, password reset, multi-factor authentication.
Course Management: Enrollments, course content access, assignment uploads.
Student Records: Access to grades, transcripts, attendance records.
Communication Tools: Announcements, email notifications, discussion forums.
Payment Gateway: Tuition fee payments, transaction history, receipt generation.
Profile Management: Updating personal information, photo upload, contact details.
Common Types of Defects:
Functionality Defects: System does not work as intended (e.g., incorrect grade
displayed).
Usability Defects: User interface issues (e.g., unclear error messages, misaligned
buttons).
Performance Defects: Slow response times or system crashes under high load.
Security Defects: Vulnerabilities like SQL injection, weak password policies.
Compatibility Defects: Issues on different devices or browsers.
2. Document Defects
Each defect should be documented with a clear and concise format to ensure it can be understood
and addressed by the development team. A typical defect report includes:
Defect ID: Unique identifier for tracking.
Title: A brief description of the defect.
Description: Detailed explanation of the issue.
Steps to Reproduce: Clear, step-by-step instructions to recreate the defect.
Expected Result: What should have happened if the system worked correctly.
Actual Result: What actually happened.
Severity: Impact level (e.g., Critical, Major, Minor).
Priority: Importance for fixing (e.g., High, Medium, Low).
Environment: Information on browser, OS, version, etc.
Attachments: Screenshots, videos, or logs as evidence.
3. Report Defects
Let’s look at some sample defect reports for an online university system:
Defect 1: Login Page - "Invalid Credentials" Message Not Displayed
Defect ID: LOGIN-001
Title: "Invalid credentials" message not displayed for incorrect login attempt
Description: When a user enters an incorrect username or password, no error message is
shown to indicate invalid credentials.
Steps to Reproduce:
1. Open the login page.
2. Enter an incorrect username and password.
3. Click on the "Login" button.
Expected Result: An error message "Invalid credentials" should appear.
Actual Result: No message is displayed; the page simply reloads.
Severity: Major
Priority: High
Environment: Chrome 92, Windows 10
Defect 2: Grade Display - Incorrect GPA Calculation
Defect ID: GRADE-003
Title: GPA calculated incorrectly for specific course combination
Description: When specific courses are enrolled together, the GPA calculation is
incorrect due to misinterpretation of course credits.
Steps to Reproduce:
1. Log in as a student with a specific course combination.
2. Navigate to "My Grades" and check GPA.
Expected Result: GPA should be calculated based on the course credits and grades.
Actual Result: Incorrect GPA is displayed.
Severity: Critical
Priority: High
Environment: Firefox 89, macOS Catalina
Defect 3: Profile Update - Profile Picture Upload Fails
Defect ID: PROFILE-008
Title: Profile picture upload fails for images above 1 MB
Description: Users are unable to upload profile pictures larger than 1 MB, although the
limit is stated to be 5 MB.
Steps to Reproduce:
1. Log in to the system.
2. Navigate to "Profile" > "Upload Profile Picture."
3. Try uploading an image file of 2 MB.
Expected Result: The image should upload successfully if it is within the 5 MB limit.
Actual Result: Error message appears, saying "File size limit exceeded."
Severity: Minor
Priority: Medium
QUESTION 3
Test Case ID Test Case Test Data Expected Actual Pass/Fail
Description Result Result
TC 001 Attempt sign-in Username: Sign-in should Sign-in failed fail
with incorrect invalidUser fail, displaying
username and Password: "Invalid
correct correctPassword123 Username or
password Password"
TC 002 Attempt sign-in Username: Sign-in should Sign-in failed fail
with correct correctUser fail, displaying
username and Password: "Invalid
incorrect wrongPassword123 Username or
password Password"
TC 003 Attempt sign-in Username: Sign-in should Sign-in failed fail
with both fakeUser fail, displaying
username and Password: "Invalid
password fakePassword Username or
incorrect Password"
TC 004 Attempt sign-in Username: [empty] Sign-in should Sign-in failed fail
with empty Password: fail, displaying
username and correctPassword123 "Username
correct cannot be
password empty"
TC 005 Attempt sign-in Username: Sign-in should Sign-in failed fail
with correct correctUser fail, displaying
username and Password: [empty] "Password
empty cannot be
password empty"
QUESTION 3
Draw CFG and DFG of a given code to analyze it in white box way.
Control Flow Graph (CFG):
Data Flow Graph (DFG):