Complete the code to import the JUnit test annotation.
import org.junit.[1];
The @Test annotation marks a method as a test method in JUnit.
Complete the code to create a test method named testAddition.
@Test
public void [1]() {
// test code here
}By convention, test methods often start with 'test' followed by the feature name, like testAddition.
Fix the error in the assertion to check if sum equals 5.
int sum = 2 + 3; assertEquals([1], sum);
The expected value should be the integer 5, not the variable sum or a string.
Fill both blanks to import the assertion and write a failing test method.
import static org.junit.Assert.[1]; @Test public void testFail() { [2]("Failing test"); }
The fail method from JUnit causes the test to fail immediately with a message.
Fill all three blanks to write a test that checks if a list contains a value.
import static org.junit.Assert.[1]; import java.util.List; @Test public void testListContains() { List<String> items = List.of("apple", "banana", "cherry"); boolean contains = items.contains("banana"); [2]("List should contain banana", contains); [3](true, contains); }
Use assertTrue to check the condition is true, and assertEquals to compare expected and actual values.
