SWT301 – Lab 1
SWT301 – Lab 1
Duration: 90 minutes
Deadline: follow the info shown on Classroom
Instructions:
IDEs like NetBeans or other similar IDEs is allowed.
Submit work in a single Word document, don’t compress your work. No other file formats
will be accepted.
Pay attention to academic integrity: Plagiarism (copying from your classmates or AI-based
tools) will result in ZERO points.
Question 1 [3 points]
The following block of Java code contains five defects related to code standards, logic and best
practices. Identify and explain each defect using the following defect report template:
- Defect ID: ____ (Unique identifier for the defect, e.g., DF001, DF002…)
- Defect Name: ____ (Descriptive name for the defect)
- Line Number: ____ (Specific line in the code where the defect occurs)
- Defect Description: ____ (A brief, one-sentence explanation of the issue)
- Fixing Solution: ____ (Description of proposed solution to fix the issue)
Page 1 of 4
SWT301 – Lab 1
Question 2 [5 points]
This Java class determine a customer’s loan approval on the following parameters: (suppose that
money unit is rounded to dollar ($1 is the minimum step).
annualIncome (double) → The annual income of the customer.
existingDebt (double) → The total existing debt of the customer.
employmentStatus (String) → “Employed” or “Unemployed”.
Calculate the cyclomatic complexity to determine the minimum number of test cases needed for all
branches coverage. (0.5 points)
Apply EP, BVA techniques to design test cases using JUnit in order to test this method. Ensure that
your test cases cover all branches. (4.5 points).
Sample Test class
Submit your test cases in your Word document. Each test case must follow this template:
ID: TC1;
Test: an employed status client with good annual income and no debt;
Input parameters: 30000, 0, “Employed”;
Page 2 of 4
SWT301 – Lab 1
Expected result: true
Test code:
Question 3 [2 points]
Given this use case for a LMS (Learning Management System). The system allows a student to
submit their assignments.
Use Case Name: Submit Assignment
Primary Actor: Student
Preconditions:
The student must be logged into the LMS.
The assignment submission period must be open.
Main Success Scenario:
1. The student logs into the LMS and navigates to the course page.
2. The student selects the assignment and clicks on "Submit."
3. The system prompts for a file upload.
4. The student uploads the file and clicks "Submit."
5. The system validates the file format and size.
6. The system stores the submission and confirms successful upload.
7. The instructor is notified of the new submission.
Alternative Scenarios:
Late submission: The system warns the student and allows submission with a penalty (if
permitted).
Invalid file format: The system rejects the file and prompts for a valid format.
Upload failure: If there is a network issue, the system allows the student to retry later.
Postconditions:
If successful, the student’s submission is stored, and the instructor can review it.
Page 3 of 4
SWT301 – Lab 1
If unsuccessful, no submission is recorded, and the student is notified.
Using use-case-based testing techniques, create functional black-box test cases to validate the
system’s behavior. Ensure that your test cases cover:
- The NF (normal flow).
- The AF (alternative flow).
- The EX (exception scenarios).
Use this template for your work and provide in your Word document.
- Test case ID:
- Test case description:
- Precondition:
- Test steps with data:
- Expected result:
- Notes:
Example:
Test case 1: Normal flow – Successful Assignment Submission
- Test case ID: TC001
- Test case description: Test submitting an assignment with valid file
- Precondition:
o The student has an active LMS account.
o The student is enrolled in the course.
o The assignment submission period is open.
o The assignment file meets the required format and size limit.
- Test steps with data:
1. Log in to the LMS with valid credentials.
2. Navigate to the course page.
3. Click on the assignment that needs to be submitted.
4. Click the "Submit" button.
5. Select a valid assignment file and upload it.
6. Click the "Submit" button to finalize submission.
7. Verify that the submission is recorded in the student’s submission history.
8. Verify that the instructor receives a notification of the new submission.
- Expected result:
o The assignment is successfully uploaded and recorded in the system.
o The student sees a confirmation message.
o The instructor receives a notification.
- Notes: NF.
--- THE END ---
Page 4 of 4