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:
Omar Karazoun 2020-12-07 19:55:13 +02:00 committed by GitHub
parent e9f73bcf0b
commit 759c99d078
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 44 additions and 47 deletions

View File

@ -23,7 +23,7 @@
package com.iluwatar.gameloop;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;

View File

@ -23,10 +23,11 @@
package com.iluwatar.gameloop;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
/**
* FixedStepGameLoop unit test class.
@ -35,12 +36,12 @@ public class FixedStepGameLoopTest {
private FixedStepGameLoop gameLoop;
@Before
@BeforeEach
public void setup() {
gameLoop = new FixedStepGameLoop();
}
@After
@AfterEach
public void tearDown() {
gameLoop = null;
}
@ -48,7 +49,7 @@ public class FixedStepGameLoopTest {
@Test
public void testUpdate() {
gameLoop.update();
Assert.assertEquals(0.01f, gameLoop.controller.getBulletPosition(), 0);
assertEquals(0.01f, gameLoop.controller.getBulletPosition(), 0);
}
}

View File

@ -23,10 +23,10 @@
package com.iluwatar.gameloop;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
/**
* FrameBasedGameLoop unit test class.
@ -35,19 +35,19 @@ public class FrameBasedGameLoopTest {
private FrameBasedGameLoop gameLoop;
@Before
@BeforeEach
public void setup() {
gameLoop = new FrameBasedGameLoop();
}
@After
@AfterEach
public void tearDown() {
gameLoop = null;
}
@Test
@org.junit.jupiter.api.Test
public void testUpdate() {
gameLoop.update();
Assert.assertEquals(0.5f, gameLoop.controller.getBulletPosition(), 0);
assertEquals(0.5f, gameLoop.controller.getBulletPosition(), 0);
}
}

View File

@ -23,34 +23,33 @@
package com.iluwatar.gameloop;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
public class GameControllerTest {
private GameController controller;
@Before
@BeforeEach
public void setup() {
controller = new GameController();
}
@After
@AfterEach
public void tearDown() {
controller = null;
}
@Test
@org.junit.jupiter.api.Test
public void testMoveBullet() {
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() {
Assert.assertEquals(controller.bullet.getPosition(), controller.getBulletPosition(), 0);
Assertions.assertEquals(controller.bullet.getPosition(), controller.getBulletPosition(), 0);
}
}

View File

@ -23,10 +23,9 @@
package com.iluwatar.gameloop;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
/**
* GameLoop unit test class.
@ -38,7 +37,7 @@ public class GameLoopTest {
/**
* Create mock implementation of GameLoop.
*/
@Before
@BeforeEach
public void setup() {
gameLoop = new GameLoop() {
@Override
@ -46,26 +45,26 @@ public class GameLoopTest {
};
}
@After
@AfterEach
public void tearDown() {
gameLoop = null;
}
@Test
@org.junit.jupiter.api.Test
public void testRun() {
gameLoop.run();
Assert.assertEquals(GameStatus.RUNNING, gameLoop.status);
Assertions.assertEquals(GameStatus.RUNNING, gameLoop.status);
}
@Test
@org.junit.jupiter.api.Test
public void testStop() {
gameLoop.stop();
Assert.assertEquals(GameStatus.STOPPED, gameLoop.status);
Assertions.assertEquals(GameStatus.STOPPED, gameLoop.status);
}
@Test
@org.junit.jupiter.api.Test
public void testIsGameRunning() {
Assert.assertFalse(gameLoop.isGameRunning());
Assertions.assertFalse(gameLoop.isGameRunning());
}
}

View File

@ -23,11 +23,9 @@
package com.iluwatar.gameloop;
import java.lang.reflect.InvocationTargetException;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
/**
* VariableStepGameLoop unit test class.
@ -36,19 +34,19 @@ public class VariableStepGameLoopTest {
private VariableStepGameLoop gameLoop;
@Before
@BeforeEach
public void setup() {
gameLoop = new VariableStepGameLoop();
}
@After
@AfterEach
public void tearDown() {
gameLoop = null;
}
@Test
@org.junit.jupiter.api.Test
public void testUpdate() {
gameLoop.update(20L);
Assert.assertEquals(0.01f, gameLoop.controller.getBulletPosition(), 0);
Assertions.assertEquals(0.01f, gameLoop.controller.getBulletPosition(), 0);
}
}