add beforeEach to tests

This commit is contained in:
DerTyp7
2023-09-08 10:29:16 +02:00
parent 9693343abb
commit a096af18af
2 changed files with 13 additions and 2 deletions

6
.idea/vcs.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View File

@@ -1,11 +1,17 @@
package de.tealfire; package de.tealfire;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
public class BowlingTest { public class BowlingTest {
private Bowling bowling;
@BeforeEach
public void setUp() {
bowling = new Bowling();
}
@Test @Test
public void testScoreGutterGame() { public void testScoreGutterGame() {
Bowling bowling = new Bowling();
for (int i = 0; i < 20; i++) { for (int i = 0; i < 20; i++) {
bowling.roll(0); bowling.roll(0);
} }
@@ -14,7 +20,6 @@ public class BowlingTest {
@Test @Test
public void testScoreGameOfOnes() { public void testScoreGameOfOnes() {
Bowling bowling = new Bowling();
for (int i = 0; i < 20; i++) { for (int i = 0; i < 20; i++) {
bowling.roll(1); bowling.roll(1);
} }