Complete the code to declare a JUnit test class.
public class [1] { }
The test class name should clearly indicate it is a test, commonly by ending with 'Test'. 'CalculatorTest' is a good name for testing Calculator class.
Complete the code to import the JUnit 5 test annotation.
import org.junit.jupiter.api.[1];
The '@Test' annotation marks a method as a test method in JUnit 5.
Fix the error in the test method declaration by completing the annotation.
public class CalculatorTest { [1] public void addNumbers() { // test code } }
The correct annotation to mark a test method in JUnit 5 is '@Test'.
Fill both blanks to declare a setup method that runs before each test.
public class CalculatorTest { [1] void [2]() { // setup code } }
'@BeforeEach' marks a method to run before each test method. 'setup' is a common method name for initialization.
Fill all three blanks to write a test method that asserts two values are equal.
import static org.junit.jupiter.api.Assertions.[1]; public class CalculatorTest { @Test void testAddition() { int expected = 5; int actual = 2 + 3; [2]([3], actual); } }
'assertEquals' is used to check if two values are equal. The first argument is the expected value, here 'expected'.