SWT301_-_FA_2024_-_PE2_3061.webp
T

SWT301_-_FA_2024_-_PE2_3061.webp

Identify and explain each defect using the following defect report template:
• Defect ID:
• Defect Name:
• Line Number:
(Unique identifier for the defect, e.g., DF001, DF002)
• Defect Description:(A brief, one-sentence explanation of the issue)
• Fixing Solution:
(Descriptive name for the defect, such as "Naming Convention Error")
(Specific line in the code where the defect occurs)
(Concise description of the code change to resolve the defect)
Question 2 (5 points):
The following Java method calculates the bonus for employee based on item year of service,salary, and performance. The method involves different calculations for various scenarios. Your task is to design test cases using JUnit for this method. You should apply equivalence partitioning and boundary value analysis for the input parameters. Additionally, ensure that your test cases cover all branches of the code to achieve 100% code coverage.
3
4
5
6
7
public class EmployeeBonusCalculator {
public double calculateBonus (int yearsOfService, double salary, boolean hasOutstandingPerformance) {
if (yearsOfService < || salary <= 0) {
throw new IllegalArgumentException("Invalid input: yearsOfService and salary must be positive.");
double bonusPercentage 0.0;
if (yearsOfService > 10) {
bonus Percentage = 0.10;
} else if (yearsOfService >= 5) (
bonus Percentage = 0.07;
} else if (yearsOfService > 2) {
bonus Percentage 0.05;
) else (
bonus Percentage = 0.02;
if (hasOutstanding Performance) {
bonus Percentage +- 0.03;
9
10

11
12
13
14
15
16
17
18
19
20日
21
22
23
Zoom

100%
Close
Activate Wir
Go to Settings to
Chưa có bình luận nào.

Thông tin

Category
SWT301
Thêm bởi
Thanh Vân
Ngày thêm
Lượt xem
2,711
Lượt bình luận
0
Rating
0.00 star(s) 0 đánh giá

Image metadata

Filename
SWT301_-_FA_2024_-_PE2_3061.webp
File size
251 KB
Dimensions
1145px x 916px

Share this media

Back
Bên trên Bottom