From e2bd09d7137bed188bb9d3fd078e91e6f6c8762b Mon Sep 17 00:00:00 2001 From: Steffen Helmke Date: Fri, 14 Jan 2022 16:45:05 +0100 Subject: [PATCH] 4gewinnt: refactored calcScore testmethods --- .../java/de/tims/viergewinnt/ai/LogicTest.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/test/java/de/tims/viergewinnt/ai/LogicTest.java b/src/test/java/de/tims/viergewinnt/ai/LogicTest.java index 2221c35..56c7cb9 100644 --- a/src/test/java/de/tims/viergewinnt/ai/LogicTest.java +++ b/src/test/java/de/tims/viergewinnt/ai/LogicTest.java @@ -68,12 +68,10 @@ class LogicTest { assertEquals(expectedResult, realResult); } - @Test - void calcScoreTest() { - int[][] playfield = new int[6][6]; - int player = 1; - int expectedResult = 0; - + @ParameterizedTest(name = "[{index}] {0} Win for Player {2} {1}") + @MethodSource("playfieldForScore") + void calcScoreTest(String testName, int[][] playfield, int player, int expectedResult) { + int realResult = testObj.calcScore(playfield, player); assertEquals(expectedResult, realResult); @@ -119,5 +117,11 @@ class LogicTest { Arguments.of("4 diagonal left player1", playfield5, 1, true) ); } + + private static Stream playfieldForScore() { + return Stream.of( + Arguments.of("emptyField", new int[6][6], 1, 0) + ); + } }