JUnit4 to JUnit5 (#1589)
* Getting @Test from JUnit5 instead of JUnit4 * Changed FixedStepGameLoopTest.java imports and tests to JUnit5 * JUnit4 to JUnit5 * JUnit4 to JUnit5 * JUnit4 to JUnit5 * JUnit4 to JUnit5
This commit is contained in:
parent
e9f73bcf0b
commit
759c99d078
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
package com.iluwatar.gameloop;
|
package com.iluwatar.gameloop;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||||
|
|
||||||
|
@ -23,10 +23,11 @@
|
|||||||
|
|
||||||
package com.iluwatar.gameloop;
|
package com.iluwatar.gameloop;
|
||||||
|
|
||||||
import org.junit.After;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import org.junit.Assert;
|
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FixedStepGameLoop unit test class.
|
* FixedStepGameLoop unit test class.
|
||||||
@ -35,12 +36,12 @@ public class FixedStepGameLoopTest {
|
|||||||
|
|
||||||
private FixedStepGameLoop gameLoop;
|
private FixedStepGameLoop gameLoop;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setup() {
|
public void setup() {
|
||||||
gameLoop = new FixedStepGameLoop();
|
gameLoop = new FixedStepGameLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@AfterEach
|
||||||
public void tearDown() {
|
public void tearDown() {
|
||||||
gameLoop = null;
|
gameLoop = null;
|
||||||
}
|
}
|
||||||
@ -48,7 +49,7 @@ public class FixedStepGameLoopTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testUpdate() {
|
public void testUpdate() {
|
||||||
gameLoop.update();
|
gameLoop.update();
|
||||||
Assert.assertEquals(0.01f, gameLoop.controller.getBulletPosition(), 0);
|
assertEquals(0.01f, gameLoop.controller.getBulletPosition(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,10 +23,10 @@
|
|||||||
|
|
||||||
package com.iluwatar.gameloop;
|
package com.iluwatar.gameloop;
|
||||||
|
|
||||||
import org.junit.After;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import org.junit.Assert;
|
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FrameBasedGameLoop unit test class.
|
* FrameBasedGameLoop unit test class.
|
||||||
@ -35,19 +35,19 @@ public class FrameBasedGameLoopTest {
|
|||||||
|
|
||||||
private FrameBasedGameLoop gameLoop;
|
private FrameBasedGameLoop gameLoop;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setup() {
|
public void setup() {
|
||||||
gameLoop = new FrameBasedGameLoop();
|
gameLoop = new FrameBasedGameLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@AfterEach
|
||||||
public void tearDown() {
|
public void tearDown() {
|
||||||
gameLoop = null;
|
gameLoop = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@org.junit.jupiter.api.Test
|
||||||
public void testUpdate() {
|
public void testUpdate() {
|
||||||
gameLoop.update();
|
gameLoop.update();
|
||||||
Assert.assertEquals(0.5f, gameLoop.controller.getBulletPosition(), 0);
|
assertEquals(0.5f, gameLoop.controller.getBulletPosition(), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,34 +23,33 @@
|
|||||||
|
|
||||||
package com.iluwatar.gameloop;
|
package com.iluwatar.gameloop;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
public class GameControllerTest {
|
public class GameControllerTest {
|
||||||
|
|
||||||
private GameController controller;
|
private GameController controller;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setup() {
|
public void setup() {
|
||||||
controller = new GameController();
|
controller = new GameController();
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@AfterEach
|
||||||
public void tearDown() {
|
public void tearDown() {
|
||||||
controller = null;
|
controller = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@org.junit.jupiter.api.Test
|
||||||
public void testMoveBullet() {
|
public void testMoveBullet() {
|
||||||
controller.moveBullet(1.5f);
|
controller.moveBullet(1.5f);
|
||||||
Assert.assertEquals(1.5f, controller.bullet.getPosition(), 0);
|
Assertions.assertEquals(1.5f, controller.bullet.getPosition(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@org.junit.jupiter.api.Test
|
||||||
public void testGetBulletPosition() {
|
public void testGetBulletPosition() {
|
||||||
Assert.assertEquals(controller.bullet.getPosition(), controller.getBulletPosition(), 0);
|
Assertions.assertEquals(controller.bullet.getPosition(), controller.getBulletPosition(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,10 +23,9 @@
|
|||||||
|
|
||||||
package com.iluwatar.gameloop;
|
package com.iluwatar.gameloop;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GameLoop unit test class.
|
* GameLoop unit test class.
|
||||||
@ -38,7 +37,7 @@ public class GameLoopTest {
|
|||||||
/**
|
/**
|
||||||
* Create mock implementation of GameLoop.
|
* Create mock implementation of GameLoop.
|
||||||
*/
|
*/
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setup() {
|
public void setup() {
|
||||||
gameLoop = new GameLoop() {
|
gameLoop = new GameLoop() {
|
||||||
@Override
|
@Override
|
||||||
@ -46,26 +45,26 @@ public class GameLoopTest {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@AfterEach
|
||||||
public void tearDown() {
|
public void tearDown() {
|
||||||
gameLoop = null;
|
gameLoop = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@org.junit.jupiter.api.Test
|
||||||
public void testRun() {
|
public void testRun() {
|
||||||
gameLoop.run();
|
gameLoop.run();
|
||||||
Assert.assertEquals(GameStatus.RUNNING, gameLoop.status);
|
Assertions.assertEquals(GameStatus.RUNNING, gameLoop.status);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@org.junit.jupiter.api.Test
|
||||||
public void testStop() {
|
public void testStop() {
|
||||||
gameLoop.stop();
|
gameLoop.stop();
|
||||||
Assert.assertEquals(GameStatus.STOPPED, gameLoop.status);
|
Assertions.assertEquals(GameStatus.STOPPED, gameLoop.status);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@org.junit.jupiter.api.Test
|
||||||
public void testIsGameRunning() {
|
public void testIsGameRunning() {
|
||||||
Assert.assertFalse(gameLoop.isGameRunning());
|
Assertions.assertFalse(gameLoop.isGameRunning());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,11 +23,9 @@
|
|||||||
|
|
||||||
package com.iluwatar.gameloop;
|
package com.iluwatar.gameloop;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.After;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* VariableStepGameLoop unit test class.
|
* VariableStepGameLoop unit test class.
|
||||||
@ -36,19 +34,19 @@ public class VariableStepGameLoopTest {
|
|||||||
|
|
||||||
private VariableStepGameLoop gameLoop;
|
private VariableStepGameLoop gameLoop;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setup() {
|
public void setup() {
|
||||||
gameLoop = new VariableStepGameLoop();
|
gameLoop = new VariableStepGameLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@AfterEach
|
||||||
public void tearDown() {
|
public void tearDown() {
|
||||||
gameLoop = null;
|
gameLoop = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@org.junit.jupiter.api.Test
|
||||||
public void testUpdate() {
|
public void testUpdate() {
|
||||||
gameLoop.update(20L);
|
gameLoop.update(20L);
|
||||||
Assert.assertEquals(0.01f, gameLoop.controller.getBulletPosition(), 0);
|
Assertions.assertEquals(0.01f, gameLoop.controller.getBulletPosition(), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user