Migrate to JUnit5

This commit is contained in:
Artur Mogozov
2017-12-31 16:29:48 +09:00
parent a20e54d0a7
commit 6694d742a3
408 changed files with 2656 additions and 2165 deletions

View File

@ -23,40 +23,36 @@
package com.iluwatar.front.controller;
import com.iluwatar.front.controller.utils.InMemoryAppender;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Date: 12/13/15 - 1:39 PM
*
* @author Jeroen Meulemeester
*/
@RunWith(Parameterized.class)
public class ViewTest {
private InMemoryAppender appender;
@Before
@BeforeEach
public void setUp() {
appender = new InMemoryAppender();
}
@After
@AfterEach
public void tearDown() {
appender.stop();
}
@Parameters
public static List<Object[]> data() {
static List<Object[]> dataProvider() {
final List<Object[]> parameters = new ArrayList<>();
parameters.add(new Object[]{new ArcherView(), "Displaying archers"});
parameters.add(new Object[]{new CatapultView(), "Displaying catapults"});
@ -65,30 +61,14 @@ public class ViewTest {
}
/**
* The view that's been tested
*/
private final View view;
/**
* The expected display message
*/
private final String displayMessage;
/**
* Create a new instance of the {@link ViewTest} with the given view and expected message
*
* @param view The view that's been tested
* @param displayMessage The expected display message
*/
public ViewTest(final View view, final String displayMessage) {
this.displayMessage = displayMessage;
this.view = view;
}
@Test
public void testDisplay() {
@ParameterizedTest
@MethodSource("dataProvider")
public void testDisplay(View view, String displayMessage) {
assertEquals(0, appender.getLogSize());
this.view.display();
view.display();
assertEquals(displayMessage, appender.getLastMessage());
assertEquals(1, appender.getLogSize());
}