소스 검색

Merge pull request #390 from superklamer/grade-school

grade-school: remove potential test pollution [Fix #371]
John Ryan 9 년 전
부모
커밋
b47805e87d
1개의 변경된 파일8개의 추가작업 그리고 2개의 파일을 삭제
  1. 8
    2
      exercises/grade-school/src/test/java/SchoolTest.java

+ 8
- 2
exercises/grade-school/src/test/java/SchoolTest.java 파일 보기

@@ -1,3 +1,4 @@
1
+import org.junit.Before;
1 2
 import org.junit.Ignore;
2 3
 import org.junit.Test;
3 4
 
@@ -15,7 +16,12 @@ import static org.junit.Assert.assertTrue;
15 16
 import static org.junit.Assert.assertEquals;
16 17
 
17 18
 public class SchoolTest {
18
-  private final School school = new School();
19
+  private School school;
20
+
21
+  @Before
22
+  public void setUp() {
23
+    school = new School();
24
+  }
19 25
 
20 26
   @Test
21 27
   public void startsWithNoStudents() {
@@ -120,7 +126,7 @@ public class SchoolTest {
120 126
       // Such as UnsupportedOperationException when an unmodifiableMap is used
121 127
     }
122 128
 
123
-    assertThat(school.studentsByGradeAlphabetical().get(grade), 
129
+    assertThat(school.studentsByGradeAlphabetical().get(grade),
124 130
       not(hasItem(studentWhichShouldNotBeAdded)));
125 131
   }
126 132
 }