Complete the code to define a JUnit test method.
@Test public void [1]() { assertEquals(4, 2 + 2); }
The method name testAddition clearly indicates the test purpose and is a valid JUnit test method name.
Complete the code to import the JUnit assertion class.
import org.junit.[1];
The Assert class contains assertion methods like assertEquals used in JUnit 4.
Fix the error in the test annotation.
public class CalculatorTest { [1] public void testSum() { assertEquals(5, 2 + 3); } }
The correct JUnit annotation for test methods is @Test with uppercase 'T'.
Fill both blanks to create a test method that checks if a list is empty.
@Test public void [1]() { List<String> list = new ArrayList<>(); assert[2](list.isEmpty()); }
The method name testListEmpty describes the test. assertTrue checks that the list is empty.
Fill all three blanks to write a test method that verifies string length.
@Test public void [1]() { String text = "hello"; assertEquals([2], text.[3]()); }
The method name testStringLength describes the test. The expected length is 5. The method to get string length is length().