Complete the code to create a test method using JUnit 5.
@Test void [1]() { assertEquals(4, 2 + 2); }
The method name additionTest clearly describes the test purpose, improving readability and test quality.
Complete the code to use the Arrange-Act-Assert pattern in the test.
@Test
void testMultiply() {
// Arrange
int a = 3;
int b = 5;
// Act
int result = a [1] b;
// Assert
assertEquals(15, result);
}The Act step performs multiplication using the * operator, matching the expected result.
Fix the error in the test assertion to correctly check for null.
@Test
void testObjectIsNull() {
Object obj = null;
assert[1](obj);
}The assertNull method correctly asserts that obj is null, improving test accuracy.
Fill both blanks to use the Given-When-Then pattern in comments.
@Test
void testDivide() {
// [1]
int numerator = 10;
int denominator = 2;
// [2]
int result = numerator / denominator;
assertEquals(5, result);
}The Given comment describes the setup, and When describes the action, following the Given-When-Then pattern.
Fill all three blanks to create a parameterized test using JUnit 5.
@ParameterizedTest
@ValueSource(ints = {2, 4, 6})
void testIsEven([1] number) {
// [2]
boolean isEven = number % 2 [3] 0;
assertTrue(isEven);
}The parameter int is used for numbers, the comment Arrange marks setup, and == checks equality, making the test clear and reusable.