Merge pull request #3976 from asturcon/beforeAfterAnnotationsJunit
BAEL-1662 Before after annotations junit
This commit is contained in:
commit
b073255b2e
|
@ -3,6 +3,7 @@ package com.baeldung.migration.junit4;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.After;
|
||||
|
@ -23,21 +24,17 @@ public class BeforeAndAfterAnnotationsTest {
|
|||
@Before
|
||||
public void init() {
|
||||
LOG.info("startup");
|
||||
|
||||
list = new ArrayList<>();
|
||||
list.add("test1");
|
||||
list.add("test2");
|
||||
list = new ArrayList<>(Arrays.asList("test1", "test2"));
|
||||
}
|
||||
|
||||
@After
|
||||
public void finalize() {
|
||||
LOG.info("finalize");
|
||||
|
||||
list.clear();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCheckingListSizeAtBeginning_ThenSizeEqualsToStartupSize() {
|
||||
public void whenCheckingListSize_ThenSizeEqualsToInit() {
|
||||
LOG.info("executing test");
|
||||
assertEquals(2, list.size());
|
||||
|
||||
|
@ -45,7 +42,7 @@ public class BeforeAndAfterAnnotationsTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void whenCheckingListSizeAtBeginningAgain_ThenSizeEqualsToStartupSize() {
|
||||
public void whenCheckingListSizeAgain_ThenSizeEqualsToInit() {
|
||||
LOG.info("executing another test");
|
||||
assertEquals(2, list.size());
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.baeldung.migration.junit5;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
|
@ -23,21 +24,17 @@ public class BeforeEachAndAfterEachAnnotationsTest {
|
|||
@BeforeEach
|
||||
public void init() {
|
||||
LOG.info("startup");
|
||||
|
||||
list = new ArrayList<>();
|
||||
list.add("test1");
|
||||
list.add("test2");
|
||||
list = new ArrayList<>(Arrays.asList("test1", "test2"));
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
public void finalize() {
|
||||
LOG.info("finalize");
|
||||
|
||||
list.clear();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCheckingListSizeAtBeginning_ThenSizeEqualsToStartupSize() {
|
||||
public void whenCheckingListSize_ThenSizeEqualsToInit() {
|
||||
LOG.info("executing test");
|
||||
assertEquals(2, list.size());
|
||||
|
||||
|
@ -45,7 +42,7 @@ public class BeforeEachAndAfterEachAnnotationsTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void whenCheckingListSizeAtBeginningAgain_ThenSizeEqualsToStartupSize() {
|
||||
public void whenCheckingListSizeAgain_ThenSizeEqualsToInit() {
|
||||
LOG.info("executing another test");
|
||||
assertEquals(2, list.size());
|
||||
|
||||
|
|
Loading…
Reference in New Issue