SWT301_-_FALL24_-_PE3_3242.webp
Nezuko94

SWT301_-_FALL24_-_PE3_3242.webp

  • Media owner Nezuko94
  • Ngày thêm
Question 2 (3 points): Assuming you are assigned to conduct the component test for the method below, please design and create the minimum component test cases (Unit Test case) needed to achieve 100% statement coverage and 100% branch coverage. (Use question 2 template).
This divideAndRound method takes two integer inputs, dividend and divisor, and returns the result of dividing the dividend by the divisor and rounding the result to the nearest integer.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
public static int divideAndRound(int dividend, int divisor) {
if (divisor == 0) {
throw new IllegalArgumentException("Divisor cannot be zero.");
}
int result dividend divisor;
if (result 0) {
if (dividend % divisor != 0) {
result--;
}
} else if (result > 0) {
if (dividend % divisor != 0) {
result++;
}
Zoom
+ 100%
Close
  • Like
Reactions: KiệtB

Thông tin

Category
SWT301
Thêm bởi
Nezuko94
Ngày thêm
Lượt xem
3,983
Lượt bình luận
1
Rating
0.00 star(s) 0 đánh giá

Image metadata

Filename
SWT301_-_FALL24_-_PE3_3242.webp
File size
205 KB
Dimensions
1920px x 990px

Share this media

Back
Bên trên Bottom