Browse Source

4gewinnt: testForWin testmethod refactored

4gewinnt
Steffen Helmke 3 years ago
committed by Lorenz Hohmann
parent
commit
a0add6efc0
  1. 2
      src/main/java/de/tims/viergewinnt/ai/Logic.java
  2. 20
      src/test/java/de/tims/viergewinnt/ai/LogicTest.java

2
src/main/java/de/tims/viergewinnt/ai/Logic.java

@ -2,6 +2,6 @@ package de.tims.viergewinnt.ai;
public class Logic {
public boolean testForWin(int[][] playfield, int player) {
return true;
return false;
}
}

20
src/test/java/de/tims/viergewinnt/ai/LogicTest.java

@ -2,8 +2,13 @@ package de.tims.viergewinnt.ai;
import static org.junit.jupiter.api.Assertions.*;
import java.util.stream.Stream;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
class LogicTest {
@ -14,14 +19,19 @@ class LogicTest {
testObj = new Logic();
}
@Test
void testForWinTest() {
int[][] testField = new int[6][6];
boolean expectedResult = false;
@ParameterizedTest(name = "[{index}] {0} Player {2} {3}")
@MethodSource("playfieldResults")
void testForWinTest(String testName, int[][] playfield, int player, boolean expectedResult) {
boolean realResult = testObj.testForWin(testField, 1);
boolean realResult = testObj.testForWin(playfield, player);
assertEquals(expectedResult, realResult);
}
private static Stream<Arguments> playfieldResults() {
return Stream.of(
Arguments.of("emptyField", new int[6][6], 1, false)
);
}
}
Loading…
Cancel
Save