diff --git a/src/test/java/game/runGameTest.java b/src/test/java/game/runGameTest.java new file mode 100644 index 0000000..588a60f --- /dev/null +++ b/src/test/java/game/runGameTest.java @@ -0,0 +1,41 @@ +package game; + +import static org.junit.jupiter.api.Assertions.*; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +class runGameTest { + + @BeforeEach + void setUp() throws Exception { + } + + @Test + public void testCountFileLinesWithThreeLines() { + //arrange + int numLines = 0; + File file; + try { + file = File.createTempFile("temp", ".txt"); + FileWriter writer = new FileWriter(file); + writer.write("Zeile 1\n"); + writer.write("Zeile 2\n"); + writer.write("Zeile 3\n"); + writer.close(); + //act + numLines = runGame.CountFileLines(file.getAbsolutePath()); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + //assert + assertEquals(4, numLines); + } + + +}