Update to JUnit5 across all modules (#1668)

* 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

* Migrating to JUnit5 and updating some Mockito patterns

* Migrating to JUnit5

* Migrating to JUnit5

* Migrating to JUnit 5

* Formatting cleanup

* Added missing scope for junit

* Fixed tests that were not running previously.

Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
This commit is contained in:
CF
2021-03-06 04:12:46 -05:00
committed by GitHub
parent e9d0b3e98c
commit c150871a94
53 changed files with 333 additions and 412 deletions

View File

@ -36,10 +36,6 @@
<artifactId>double-buffer</artifactId>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>

View File

@ -23,14 +23,14 @@
package com.iluwatar.doublebuffer;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import org.junit.jupiter.api.Test;
/**
* App unit test.
*/
public class AppTest {
class AppTest {
/**
* Issue: Add at least one assertion to this test case.
@ -40,7 +40,7 @@ public class AppTest {
*/
@Test
public void shouldExecuteApplicationWithoutException() {
void shouldExecuteApplicationWithoutException() {
assertDoesNotThrow(() -> App.main(new String[]{}));
}

View File

@ -23,17 +23,19 @@
package com.iluwatar.doublebuffer;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;
import java.util.Arrays;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* FrameBuffer unit test.
*/
public class FrameBufferTest {
class FrameBufferTest {
@Test
public void testClearAll() {
void testClearAll() {
try {
var field = FrameBuffer.class.getDeclaredField("pixels");
var pixels = new Pixel[FrameBuffer.HEIGHT * FrameBuffer.WIDTH];
@ -43,14 +45,14 @@ public class FrameBufferTest {
field.setAccessible(true);
field.set(frameBuffer, pixels);
frameBuffer.clearAll();
Assert.assertEquals(Pixel.WHITE, frameBuffer.getPixels()[0]);
assertEquals(Pixel.WHITE, frameBuffer.getPixels()[0]);
} catch (NoSuchFieldException | IllegalAccessException e) {
Assert.fail("Fail to modify field access.");
fail("Fail to modify field access.");
}
}
@Test
public void testClear() {
void testClear() {
try {
var field = FrameBuffer.class.getDeclaredField("pixels");
var pixels = new Pixel[FrameBuffer.HEIGHT * FrameBuffer.WIDTH];
@ -60,21 +62,21 @@ public class FrameBufferTest {
field.setAccessible(true);
field.set(frameBuffer, pixels);
frameBuffer.clear(0, 0);
Assert.assertEquals(Pixel.WHITE, frameBuffer.getPixels()[0]);
assertEquals(Pixel.WHITE, frameBuffer.getPixels()[0]);
} catch (NoSuchFieldException | IllegalAccessException e) {
Assert.fail("Fail to modify field access.");
fail("Fail to modify field access.");
}
}
@Test
public void testDraw() {
void testDraw() {
var frameBuffer = new FrameBuffer();
frameBuffer.draw(0, 0);
Assert.assertEquals(Pixel.BLACK, frameBuffer.getPixels()[0]);
assertEquals(Pixel.BLACK, frameBuffer.getPixels()[0]);
}
@Test
public void testGetPixels() {
void testGetPixels() {
try {
var field = FrameBuffer.class.getDeclaredField("pixels");
var pixels = new Pixel[FrameBuffer.HEIGHT * FrameBuffer.WIDTH];
@ -83,9 +85,9 @@ public class FrameBufferTest {
var frameBuffer = new FrameBuffer();
field.setAccessible(true);
field.set(frameBuffer, pixels);
Assert.assertEquals(pixels, frameBuffer.getPixels());
assertEquals(pixels, frameBuffer.getPixels());
} catch (NoSuchFieldException | IllegalAccessException e) {
Assert.fail("Fail to modify field access.");
fail("Fail to modify field access.");
}
}

View File

@ -23,17 +23,19 @@
package com.iluwatar.doublebuffer;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;
import java.util.ArrayList;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Scene unit tests.
*/
public class SceneTest {
class SceneTest {
@Test
public void testGetBuffer() {
void testGetBuffer() {
try {
var scene = new Scene();
var field1 = Scene.class.getDeclaredField("current");
@ -46,14 +48,14 @@ public class SceneTest {
var field2 = Scene.class.getDeclaredField("frameBuffers");
field2.setAccessible(true);
field2.set(scene, frameBuffers);
Assert.assertEquals(frameBuffer, scene.getBuffer());
assertEquals(frameBuffer, scene.getBuffer());
} catch (NoSuchFieldException | IllegalAccessException e) {
Assert.fail("Fail to access private field.");
fail("Fail to access private field.");
}
}
@Test
public void testDraw() {
void testDraw() {
try {
var scene = new Scene();
var field1 = Scene.class.getDeclaredField("current");
@ -63,10 +65,10 @@ public class SceneTest {
field2.setAccessible(true);
field2.set(scene, 1);
scene.draw(new ArrayList<>());
Assert.assertEquals(1, field1.get(scene));
Assert.assertEquals(0, field2.get(scene));
assertEquals(1, field1.get(scene));
assertEquals(0, field2.get(scene));
} catch (NoSuchFieldException | IllegalAccessException e) {
Assert.fail("Fail to access private field");
fail("Fail to access private field");
}
}
}