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