Browse Source

refactoring: Replace try/catch with throws Exception

master
Leon Montag 2 years ago
parent
commit
94ce8167cd
  1. 15
      src/test/java/game/runGameTest.java

15
src/test/java/game/runGameTest.java

@ -16,11 +16,10 @@ class runGameTest {
} }
@Test @Test
public void testCountFileLinesWithThreeLines() {
public void testCountFileLinesWithThreeLines() throws Exception {
// arrange // arrange
int numLines = 0; int numLines = 0;
File file; File file;
try {
file = File.createTempFile("temp", ".txt"); file = File.createTempFile("temp", ".txt");
FileWriter writer = new FileWriter(file); FileWriter writer = new FileWriter(file);
writer.write("Zeile 1\n"); writer.write("Zeile 1\n");
@ -29,18 +28,14 @@ class runGameTest {
writer.close(); writer.close();
// act // act
numLines = runGame.CountFileLines(file.getAbsolutePath()); numLines = runGame.CountFileLines(file.getAbsolutePath());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// assert // assert
assertEquals(4, numLines); assertEquals(4, numLines);
} }
@Test @Test
public void testReadFile() {
public void testReadFile() throws Exception {
File file; File file;
try {
file = File.createTempFile("temp", ".txt"); file = File.createTempFile("temp", ".txt");
FileWriter writer = new FileWriter(file); FileWriter writer = new FileWriter(file);
writer.write("Zeile 1\n"); writer.write("Zeile 1\n");
@ -51,10 +46,6 @@ class runGameTest {
assertEquals("Zeile 1", lines[0]); assertEquals("Zeile 1", lines[0]);
assertEquals("Zeile 2", lines[1]); assertEquals("Zeile 2", lines[1]);
assertEquals("Zeile 3", lines[2]); assertEquals("Zeile 3", lines[2]);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} }

Loading…
Cancel
Save