Migrate to JUnit5
This commit is contained in:
@ -34,8 +34,18 @@
|
||||
<artifactId>specification</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-params</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -22,7 +22,7 @@
|
||||
*/
|
||||
package com.iluwatar.specification.app;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -25,30 +25,26 @@ package com.iluwatar.specification.creature;
|
||||
import com.iluwatar.specification.property.Color;
|
||||
import com.iluwatar.specification.property.Movement;
|
||||
import com.iluwatar.specification.property.Size;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
/**
|
||||
* Date: 12/29/15 - 7:47 PM
|
||||
*
|
||||
* @author Jeroen Meulemeester
|
||||
*/
|
||||
@RunWith(Parameterized.class)
|
||||
public class CreatureTest {
|
||||
|
||||
/**
|
||||
* @return The tested {@link Creature} instance and its expected specs
|
||||
*/
|
||||
@Parameterized.Parameters
|
||||
public static Collection<Object[]> data() {
|
||||
public static Collection<Object[]> dataProvider() {
|
||||
return Arrays.asList(
|
||||
new Object[]{new Dragon(), "Dragon", Size.LARGE, Movement.FLYING, Color.RED},
|
||||
new Object[]{new Goblin(), "Goblin", Size.SMALL, Movement.WALKING, Color.GREEN},
|
||||
@ -59,71 +55,36 @@ public class CreatureTest {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The tested creature
|
||||
*/
|
||||
private final Creature testedCreature;
|
||||
|
||||
/**
|
||||
* The expected name of the tested creature
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* The expected size of the tested creature
|
||||
*/
|
||||
private final Size size;
|
||||
|
||||
/**
|
||||
* The expected movement type of the tested creature
|
||||
*/
|
||||
private final Movement movement;
|
||||
|
||||
/**
|
||||
* The expected color of the tested creature
|
||||
*/
|
||||
private final Color color;
|
||||
|
||||
/**
|
||||
* @param testedCreature The tested creature
|
||||
* @param name The expected name of the creature
|
||||
* @param size The expected size of the creature
|
||||
* @param movement The expected movement type of the creature
|
||||
* @param color The expected color of the creature
|
||||
*/
|
||||
public CreatureTest(final Creature testedCreature, final String name, final Size size,
|
||||
final Movement movement, final Color color) {
|
||||
this.testedCreature = testedCreature;
|
||||
this.name = name;
|
||||
this.size = size;
|
||||
this.movement = movement;
|
||||
this.color = color;
|
||||
@ParameterizedTest
|
||||
@MethodSource("dataProvider")
|
||||
public void testGetName(Creature testedCreature, String name) throws Exception {
|
||||
assertEquals(name, testedCreature.getName());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetName() throws Exception {
|
||||
assertEquals(this.name, this.testedCreature.getName());
|
||||
@ParameterizedTest
|
||||
@MethodSource("dataProvider")
|
||||
public void testGetSize(Creature testedCreature, String name, Size size) throws Exception {
|
||||
assertEquals(size, testedCreature.getSize());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSize() throws Exception {
|
||||
assertEquals(this.size, this.testedCreature.getSize());
|
||||
@ParameterizedTest
|
||||
@MethodSource("dataProvider")
|
||||
public void testGetMovement(Creature testedCreature, String name, Size size, Movement movement) throws Exception {
|
||||
assertEquals(movement, testedCreature.getMovement());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMovement() throws Exception {
|
||||
assertEquals(this.movement, this.testedCreature.getMovement());
|
||||
@ParameterizedTest
|
||||
@MethodSource("dataProvider")
|
||||
public void testGetColor(Creature testedCreature, String name, Size size, Movement movement,
|
||||
Color color) throws Exception {
|
||||
assertEquals(color, testedCreature.getColor());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetColor() throws Exception {
|
||||
assertEquals(this.color, this.testedCreature.getColor());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToString() throws Exception {
|
||||
final String toString = this.testedCreature.toString();
|
||||
@ParameterizedTest
|
||||
@MethodSource("dataProvider")
|
||||
public void testToString(Creature testedCreature, String name, Size size, Movement movement,
|
||||
Color color) throws Exception {
|
||||
final String toString = testedCreature.toString();
|
||||
assertNotNull(toString);
|
||||
assertEquals(
|
||||
String.format("%s [size=%s, movement=%s, color=%s]", name, size, movement, color),
|
||||
|
@ -24,11 +24,10 @@ package com.iluwatar.specification.selector;
|
||||
|
||||
import com.iluwatar.specification.creature.Creature;
|
||||
import com.iluwatar.specification.property.Color;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
|
@ -23,13 +23,11 @@
|
||||
package com.iluwatar.specification.selector;
|
||||
|
||||
import com.iluwatar.specification.creature.Creature;
|
||||
import com.iluwatar.specification.property.Color;
|
||||
import com.iluwatar.specification.property.Movement;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
|
@ -24,11 +24,10 @@ package com.iluwatar.specification.selector;
|
||||
|
||||
import com.iluwatar.specification.creature.Creature;
|
||||
import com.iluwatar.specification.property.Size;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
|
Reference in New Issue
Block a user