Souvatzis Vasilios 9 лет назад
Родитель
Сommit
92a34f6961
1 измененных файлов: 15 добавлений и 7 удалений
  1. 15
    7
      exercises/beer-song/src/test/java/BeerSongTest.java

+ 15
- 7
exercises/beer-song/src/test/java/BeerSongTest.java Просмотреть файл

@@ -1,15 +1,23 @@
1 1
 import org.junit.Test;
2 2
 import org.junit.Ignore;
3
+import org.junit.Before;
3 4
 
4 5
 import static org.junit.Assert.assertEquals;
5 6
 
6 7
 public class BeerSongTest {
7 8
 
9
+    private BeerSong beerSong;
10
+
11
+    @Before
12
+    public void setup(){
13
+        beerSong = new BeerSong();
14
+    }
15
+
8 16
     @Test
9 17
     public void singFirstVerse() {
10 18
         assertEquals("99 bottles of beer on the wall, 99 bottles of beer.\n" +
11 19
                         "Take one down and pass it around, 98 bottles of beer on the wall.\n\n",
12
-                new BeerSong().verse(99));
20
+                beerSong.verse(99));
13 21
     }
14 22
 
15 23
     @Ignore
@@ -17,7 +25,7 @@ public class BeerSongTest {
17 25
     public void singMiddleVerse() {
18 26
         assertEquals("44 bottles of beer on the wall, 44 bottles of beer.\n" +
19 27
                         "Take one down and pass it around, 43 bottles of beer on the wall.\n\n",
20
-                new BeerSong().verse(44));
28
+                beerSong.verse(44));
21 29
     }
22 30
 
23 31
     @Ignore
@@ -25,7 +33,7 @@ public class BeerSongTest {
25 33
     public void singThirdToLastVerse() {
26 34
         assertEquals("2 bottles of beer on the wall, 2 bottles of beer.\n" +
27 35
                         "Take one down and pass it around, 1 bottle of beer on the wall.\n\n",
28
-                new BeerSong().verse(2));
36
+                beerSong.verse(2));
29 37
     }
30 38
 
31 39
     @Ignore
@@ -33,7 +41,7 @@ public class BeerSongTest {
33 41
     public void singPenultimateVerse() {
34 42
         assertEquals("1 bottle of beer on the wall, 1 bottle of beer.\n" +
35 43
                         "Take it down and pass it around, no more bottles of beer on the wall.\n\n",
36
-                new BeerSong().verse(1));
44
+                beerSong.verse(1));
37 45
     }
38 46
 
39 47
     @Ignore
@@ -41,7 +49,7 @@ public class BeerSongTest {
41 49
     public void singLastVerse() {
42 50
         assertEquals("No more bottles of beer on the wall, no more bottles of beer.\n" +
43 51
                         "Go to the store and buy some more, 99 bottles of beer on the wall.\n\n",
44
-                new BeerSong().verse(0));
52
+                beerSong.verse(0));
45 53
     }
46 54
 
47 55
     @Ignore
@@ -55,7 +63,7 @@ public class BeerSongTest {
55 63
                         "Take it down and pass it around, no more bottles of beer on the wall.\n\n" +
56 64
                         "No more bottles of beer on the wall, no more bottles of beer.\n" +
57 65
                         "Go to the store and buy some more, 99 bottles of beer on the wall.\n\n",
58
-                new BeerSong().sing(3,0));
66
+                beerSong.sing(3,0));
59 67
     }
60 68
 
61 69
     @Ignore
@@ -161,7 +169,7 @@ public class BeerSongTest {
161 169
                         "2 bottles of beer on the wall, 2 bottles of beer.\nTake one down and pass it around, 1 bottle of beer on the wall.\n\n" +
162 170
                         "1 bottle of beer on the wall, 1 bottle of beer.\nTake it down and pass it around, no more bottles of beer on the wall.\n\n" +
163 171
                         "No more bottles of beer on the wall, no more bottles of beer.\nGo to the store and buy some more, 99 bottles of beer on the wall.\n\n",
164
-                new BeerSong().singSong());
172
+                beerSong.singSong());
165 173
     }
166 174
 
167 175
 }