Question 1: Black Box Testing
ID Pre -
Expected
Test Case Description Conditio Test Case Procedure
Output
n
1 Valid Login 1. Open application - Redirecting to
2. Enter a login account or below one home screen
2.1. Email = - Notifying
"[email protected]" "Login
2.2 Password = "123456" Successful"
3. Click "Submit" button toast at the
bottom
2 Invalid Email 1. Open application Notify "Invald
2. Enter a login account or below one Email
2.1. Email = "duongtrinhgmail.com" or Password"
2.2 Password = "123456"
3. Click "Submit" button
3 Invalid Password 1. Open application Notify "Invald
2. Enter a login account or below one Email
2.1. Email = or Password"
"[email protected]"
2.2 Password = "123"
3. Click "Submit" button
4 Empty Email Fields 1. Open application Notify "Email is
2. Enter a login account or below one empty"
2.1. Email = ""
2.2 Password = "123456"
3. Click "Submit" button
5 Empty Password 1. Open application Notify "Password
Fields 2. Enter a login account or below one is Empty"
2.1. Email =
"[email protected]"
2.2 Password = ""
3. Click "Submit" button
Question 2: White Box Testing
a) Identify boundary test cases for the factorial function.
Boudary Test case:
1. n = 1
2. n = 0
3. n = -1
b) Design test cases to achieve 100% statement coverage for the factorial function.
Test Cases for 100% Statement Coverage:
Test Case Input Expected Output
ID
1 n=1 1
2 n=0 1
3 n = -1 Error
4 n=5 120
Question 3: Code Reading Comprehensive
Purpose of the bubbleSort function:
The purpose of the bubbleSort function is to sort an array of integers (arr) in
ascending order. Bubble Sort works by repeatedly stepping through the list, comparing
adjacent elements, and swapping them if they are in the wrong order. This process is
repeated until no more swaps are needed, meaning the list is sorted.
Explanation of Each Part
● Outer Loop (for (int i = 0; i < n - 1; i++)):
○ This loop controls the number of passes needed to sort the array. After each
pass, the largest unsorted element "bubbles" to its correct position at the end
of the array.
○ It runs n - 1 times, where n is the length of the array.
● Inner Loop (for (int j = 0; j < n - i - 1; j++)):
○ This loop iterates through the array up to the unsorted part and compares
adjacent elements.
○ If an element is greater than the one next to it, they are swapped to move the
larger element toward the end of the array.
● Swapping Mechanism:
○ The code swaps adjacent elements if they are out of order (i.e., if arr[j] >
arr[j + 1]), using a temporary variable temp.
Potential Bugs or Issues:
Efficiency:
● Bubble Sort has a time complexity of O(n^2), which is not efficient for large datasets.
For small arrays, it works but is generally slower compared to more efficient sorting
algorithms like Quick Sort or Merge Sort.
Edge Case:
● If the input array is empty (arr.length == 0), the function currently works
correctly as the loop will not execute. However, it might be a good practice to add a
check for empty or null input.
Optimization Opportunity:
● This implementation lacks a flag to detect if the array is already sorted. In cases
where the array is nearly or fully sorted, the function will still go through unnecessary
passes.
Null Array Handling:
● The code does not check if array is null. If a null array is passed to the function,
it will throw a NullPointerException.
Question 4: Find Bug and Detect
You are testing a mobile application for a calendar feature. During testing, you notice that
events scheduled for the current date are not displaying correctly. Identify the potential bug
in the calendar feature and suggest steps to reproduce and diagnose the issue.
Bug Description:
Date and Time Zone Mismatch:
● The application may not correctly handle time zones, causing events scheduled for
"today" to display at incorrect times or on the wrong date.
Current Date Filter Logic:
● The logic filtering events for the current date might be incorrect, failing to identify
events scheduled within the bounds of today's date.
Date Format Parsing Error:
● If dates are stored or retrieved in an inconsistent format, the app might misinterpret
or fail to display events for the current date.
Caching or Data Refresh Issue:
● The app may be displaying cached data without refreshing it to show newly added or
updated events.
UI Rendering or Display Logic:
● The UI layer responsible for displaying events may not correctly load or render
events scheduled for the current date.
Steps to Reproduce:
1. Add Events for the Current Date:
● Schedule one or more events specifically for today at different times.
● Verify that these events appear in the event list immediately after creation.
2. Check Across Different Views:
● Navigate to different views, such as day, week, and month views, to see if events
appear correctly in any of them or if they fail across all views.
3. Refresh or Restart the App:
● Close and reopen the app to see if the issue persists. If the events display correctly
after restarting, this could indicate a caching or data-refresh problem.
4. Change the System Date and Time:
● Adjust the device's date to tomorrow, then back to today, and see if the issue
persists. This step helps identify if the app correctly recognizes the current date or if
there’s a problem with real-time date detection.
5. Test Across Time Zones:
● Change the device time zone to a different region, particularly one in a different day
(e.g., just before and after midnight) to see if the app correctly displays today’s
events in all zones.
Diagnosis Steps:
1. Inspect Date and Time Zone Logic: Check the code responsible for filtering events
by date and ensure it accounts for the user's time zone accurately.
2. Log Date Parsing: Add logs for date parsing to ensure that today’s date is correctly
recognized and that events scheduled for today are included in the results.
3. Review Caching and Refresh Mechanism: Ensure that the app correctly fetches
updated data when the user returns to the calendar view or refreshes it.
4. UI Rendering Check: Verify that the logic for rendering events on the calendar
explicitly includes events for the current date.
Question 5: Test Level
Differences between Unit Testing and System Testing:
Examples of Scenarios:
Unit Testing:
● Testing a function that calculates the sum of two numbers.
● Verifying that a data transformation function correctly formats a date.
● Ensuring that a method handling business logic returns the correct results when
given different inputs.
● Checking that a function throws the expected error when given invalid inputs.
System Testing:
● Verifying that a user can log in, navigate to a dashboard, and view personalized data.
● Testing that all components of an e-commerce checkout process (cart, payment
gateway, and confirmation page) function correctly.
● Ensuring that an email notification is sent to a user after they reset their password.
● Checking that a multi-step form works end-to-end, validating data across each step,
and correctly saving the final submission.