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

@@ -34,8 +34,18 @@
<artifactId>prototype</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>

View File

@@ -22,7 +22,7 @@
*/
package com.iluwatar.prototype;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
*

View File

@@ -22,9 +22,9 @@
*/
package com.iluwatar.prototype;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;

View File

@@ -22,27 +22,24 @@
*/
package com.iluwatar.prototype;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import java.util.Arrays;
import java.util.Collection;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNotSame;
import static org.junit.jupiter.api.Assertions.assertSame;
/**
* Date: 12/28/15 - 8:45 PM
* @param <P> Prototype
* @author Jeroen Meulemeester
*/
@RunWith(Parameterized.class)
public class PrototypeTest<P extends Prototype> {
@Parameterized.Parameters
public static Collection<Object[]> data() {
static Collection<Object[]> dataProvider() {
return Arrays.asList(
new Object[]{new OrcBeast(), "Orcish wolf"},
new Object[]{new OrcMage(), "Orcish mage"},
@@ -53,35 +50,15 @@ public class PrototypeTest<P extends Prototype> {
);
}
/**
* The tested prototype instance
*/
private final P testedPrototype;
@ParameterizedTest
@MethodSource("dataProvider")
public void testPrototype(P testedPrototype, String expectedToString) throws Exception {
assertEquals(expectedToString, testedPrototype.toString());
/**
* The expected {@link Prototype#toString()} value
*/
private final String expectedToString;
/**
* Create a new test instance, using the given test object and expected value
*
* @param testedPrototype The tested prototype instance
* @param expectedToString The expected {@link Prototype#toString()} value
*/
public PrototypeTest(final P testedPrototype, final String expectedToString) {
this.expectedToString = expectedToString;
this.testedPrototype = testedPrototype;
}
@Test
public void testPrototype() throws Exception {
assertEquals(this.expectedToString, this.testedPrototype.toString());
final Object clone = this.testedPrototype.clone();
final Object clone = testedPrototype.clone();
assertNotNull(clone);
assertNotSame(clone, this.testedPrototype);
assertSame(this.testedPrototype.getClass(), clone.getClass());
assertNotSame(clone, testedPrototype);
assertSame(testedPrototype.getClass(), clone.getClass());
}
}