import org.junit.jupiter.api.*; public class ListTest { private NewList list = new NewList(); @BeforeEach public void addElements() { list.add("Every"); list.add("Good"); list.add("Boy"); list.add("Deserves"); } @Test public void testGet() { Assertions.assertEquals("Good", list.get(1)); } @Test public void testGetException() { try { String value = list.get(4); Assertions.fail("An exception should have been thrown"); } catch (IndexOutOfBoundsException e) {} } @Test public void testAddAll() { NewList list2 = new NewList(); list2.add("I"); list2.add("Believe"); list2.addAll(list); Assertions.assertEquals("Boy", list2.get(4)); } @Test public void testEmpty() { Assertions.assertFalse(list.isEmpty()); list.clear(); Assertions.assertTrue(list.isEmpty()); } @Test public void testSize() { Assertions.assertEquals(4, list.size()); } @Test public void testIndexOf() { list.remove(1); //noinspection StringOperationCanBeSimplified Assertions.assertEquals(2, list.indexOf(new String("Deserves"))); } }