diff --git a/src/test/java/game/runGameTest.java b/src/test/java/game/runGameTest.java index 6588d69..52b7c87 100644 --- a/src/test/java/game/runGameTest.java +++ b/src/test/java/game/runGameTest.java @@ -16,45 +16,36 @@ class runGameTest { } @Test - public void testCountFileLinesWithThreeLines() { + public void testCountFileLinesWithThreeLines() throws Exception { // 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(); - } + 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()); + // assert assertEquals(4, numLines); } @Test - public void testReadFile() { + public void testReadFile() throws Exception { 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(); - String[] lines = runGame.readFile(file.getAbsolutePath()); - assertEquals("Zeile 1", lines[0]); - assertEquals("Zeile 2", lines[1]); - assertEquals("Zeile 3", lines[2]); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + 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(); + String[] lines = runGame.readFile(file.getAbsolutePath()); + assertEquals("Zeile 1", lines[0]); + assertEquals("Zeile 2", lines[1]); + assertEquals("Zeile 3", lines[2]); }