arrayList * shorter tests names

This commit is contained in:
Marcos Lopez Gonzalez 2018-04-10 22:16:50 +02:00
parent 74e66a8ba9
commit b1e230de41
2 changed files with 8 additions and 14 deletions

View File

@ -3,6 +3,7 @@ package com.baeldung.migration.junit4;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import org.junit.After; import org.junit.After;
@ -23,21 +24,17 @@ public class BeforeAndAfterAnnotationsTest {
@Before @Before
public void init() { public void init() {
LOG.info("startup"); LOG.info("startup");
list = new ArrayList<>(Arrays.asList("test1", "test2"));
list = new ArrayList<>();
list.add("test1");
list.add("test2");
} }
@After @After
public void finalize() { public void finalize() {
LOG.info("finalize"); LOG.info("finalize");
list.clear(); list.clear();
} }
@Test @Test
public void whenCheckingListSizeAtBeginning_ThenSizeEqualsToStartupSize() { public void whenCheckingListSize_ThenSizeEqualsToInit() {
LOG.info("executing test"); LOG.info("executing test");
assertEquals(2, list.size()); assertEquals(2, list.size());
@ -45,7 +42,7 @@ public class BeforeAndAfterAnnotationsTest {
} }
@Test @Test
public void whenCheckingListSizeAtBeginningAgain_ThenSizeEqualsToStartupSize() { public void whenCheckingListSizeAgain_ThenSizeEqualsToInit() {
LOG.info("executing another test"); LOG.info("executing another test");
assertEquals(2, list.size()); assertEquals(2, list.size());

View File

@ -3,6 +3,7 @@ package com.baeldung.migration.junit5;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
@ -23,21 +24,17 @@ public class BeforeEachAndAfterEachAnnotationsTest {
@BeforeEach @BeforeEach
public void init() { public void init() {
LOG.info("startup"); LOG.info("startup");
list = new ArrayList<>(Arrays.asList("test1", "test2"));
list = new ArrayList<>();
list.add("test1");
list.add("test2");
} }
@AfterEach @AfterEach
public void finalize() { public void finalize() {
LOG.info("finalize"); LOG.info("finalize");
list.clear(); list.clear();
} }
@Test @Test
public void whenCheckingListSizeAtBeginning_ThenSizeEqualsToStartupSize() { public void whenCheckingListSize_ThenSizeEqualsToInit() {
LOG.info("executing test"); LOG.info("executing test");
assertEquals(2, list.size()); assertEquals(2, list.size());
@ -45,7 +42,7 @@ public class BeforeEachAndAfterEachAnnotationsTest {
} }
@Test @Test
public void whenCheckingListSizeAtBeginningAgain_ThenSizeEqualsToStartupSize() { public void whenCheckingListSizeAgain_ThenSizeEqualsToInit() {
LOG.info("executing another test"); LOG.info("executing another test");
assertEquals(2, list.size()); assertEquals(2, list.size());