Updated update-method module to JUnit 5 (#1542)
* Updated saga to JUnit 5 * Update fix for CI job in trampoline module * Updated update-method module to JUnit 5 * Upgraded to latest JUnit Jupiter JUnit 4 is not needed when using JUnit-Vintage * Reverted change to access modifier on Trampoline * Cleanup to resolve code smells * Formatting * Formatting Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
This commit is contained in:
@ -35,10 +35,6 @@
|
||||
|
||||
<artifactId>update-method</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
|
@ -23,14 +23,14 @@
|
||||
|
||||
package com.iluwatar.updatemethod;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
|
||||
public class AppTest {
|
||||
class AppTest {
|
||||
|
||||
@Test
|
||||
public void shouldExecuteApplicationWithoutException() {
|
||||
void shouldExecuteApplicationWithoutException() {
|
||||
assertDoesNotThrow(() -> App.main(new String[]{}));
|
||||
}
|
||||
}
|
||||
|
@ -23,56 +23,60 @@
|
||||
|
||||
package com.iluwatar.updatemethod;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class SkeletonTest {
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
private Skeleton skeleton;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
class SkeletonTest {
|
||||
|
||||
private static Skeleton skeleton;
|
||||
|
||||
@BeforeAll
|
||||
public static void setup() {
|
||||
skeleton = new Skeleton(1);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
@AfterAll
|
||||
public static void tearDown() {
|
||||
skeleton = null;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateForPatrollingLeft() {
|
||||
void testUpdateForPatrollingLeft() {
|
||||
skeleton.patrollingLeft = true;
|
||||
skeleton.setPosition(50);
|
||||
skeleton.update();
|
||||
Assert.assertEquals(49, skeleton.getPosition());
|
||||
assertEquals(49, skeleton.getPosition());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateForPatrollingRight() {
|
||||
void testUpdateForPatrollingRight() {
|
||||
skeleton.patrollingLeft = false;
|
||||
skeleton.setPosition(50);
|
||||
skeleton.update();
|
||||
Assert.assertEquals(51, skeleton.getPosition());
|
||||
assertEquals(51, skeleton.getPosition());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateForReverseDirectionFromLeftToRight() {
|
||||
void testUpdateForReverseDirectionFromLeftToRight() {
|
||||
skeleton.patrollingLeft = true;
|
||||
skeleton.setPosition(1);
|
||||
skeleton.update();
|
||||
Assert.assertEquals(0, skeleton.getPosition());
|
||||
Assert.assertEquals(false, skeleton.patrollingLeft);
|
||||
assertEquals(0, skeleton.getPosition());
|
||||
assertFalse(skeleton.patrollingLeft);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateForReverseDirectionFromRightToLeft() {
|
||||
void testUpdateForReverseDirectionFromRightToLeft() {
|
||||
skeleton.patrollingLeft = false;
|
||||
skeleton.setPosition(99);
|
||||
skeleton.update();
|
||||
Assert.assertEquals(100, skeleton.getPosition());
|
||||
Assert.assertEquals(true, skeleton.patrollingLeft);
|
||||
assertEquals(100, skeleton.getPosition());
|
||||
assertTrue(skeleton.patrollingLeft);
|
||||
}
|
||||
}
|
||||
|
@ -23,36 +23,37 @@
|
||||
|
||||
package com.iluwatar.updatemethod;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class StatueTest {
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
private Statue statue;
|
||||
class StatueTest {
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
private static Statue statue;
|
||||
|
||||
@BeforeAll
|
||||
public static void setup() {
|
||||
statue = new Statue(1, 20);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
@AfterAll
|
||||
public static void tearDown() {
|
||||
statue = null;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateForPendingShoot() {
|
||||
void testUpdateForPendingShoot() {
|
||||
statue.frames = 10;
|
||||
statue.update();
|
||||
Assert.assertEquals(11, statue.frames);
|
||||
assertEquals(11, statue.frames);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateForShooting() {
|
||||
void testUpdateForShooting() {
|
||||
statue.frames = 19;
|
||||
statue.update();
|
||||
Assert.assertEquals(0, statue.frames);
|
||||
assertEquals(0, statue.frames);
|
||||
}
|
||||
}
|
||||
|
@ -23,41 +23,44 @@
|
||||
|
||||
package com.iluwatar.updatemethod;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class WorldTest {
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
private World world;
|
||||
class WorldTest {
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
private static World world;
|
||||
|
||||
@BeforeAll
|
||||
public static void setup() {
|
||||
world = new World();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
@AfterAll
|
||||
public static void tearDown() {
|
||||
world = null;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRun() {
|
||||
void testRun() {
|
||||
world.run();
|
||||
Assert.assertEquals(true, world.isRunning);
|
||||
assertTrue(world.isRunning);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStop() {
|
||||
void testStop() {
|
||||
world.stop();
|
||||
Assert.assertEquals(false, world.isRunning);
|
||||
assertFalse(world.isRunning);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddEntity() {
|
||||
void testAddEntity() {
|
||||
var entity = new Skeleton(1);
|
||||
world.addEntity(entity);
|
||||
Assert.assertEquals(entity, world.entities.get(0));
|
||||
assertEquals(entity, world.entities.get(0));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user