Skip to content

Commit 381d084

Browse files
committed
test: 공통 초기화 로직 BeforeEach 도입
1 parent 15bd177 commit 381d084

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

src/test/java/io/suhan/lotto/model/executor/DrawExecutorTest.java

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,29 @@
1111
import java.util.List;
1212
import java.util.Set;
1313
import org.assertj.core.api.SoftAssertions;
14+
import org.junit.jupiter.api.BeforeEach;
1415
import org.junit.jupiter.api.DisplayNameGeneration;
1516
import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores;
1617
import org.junit.jupiter.api.Test;
1718

1819
@SuppressWarnings("NonAsciiCharacters")
1920
@DisplayNameGeneration(ReplaceUnderscores.class)
2021
public class DrawExecutorTest {
21-
@Test
22-
void 당첨번호와_로또를_비교할_수_있다() {
23-
LottoRegistry registry = new LottoRegistry();
22+
private LottoRegistry registry;
23+
private Lotto winningLotto;
2424

25+
@BeforeEach
26+
void setUp() {
27+
registry = new LottoRegistry();
2528
Set<LottoNumber> numbers = Set.of(
2629
new LottoNumber(1), new LottoNumber(2), new LottoNumber(3),
27-
new LottoNumber(4), new LottoNumber(5), new LottoNumber(6));
28-
29-
Lotto winningLotto = Lotto.of(numbers);
30+
new LottoNumber(4), new LottoNumber(5), new LottoNumber(6)
31+
);
32+
winningLotto = Lotto.of(numbers);
33+
}
3034

35+
@Test
36+
void 당첨번호와_로또를_비교할_수_있다() {
3137
registry.add(winningLotto);
3238

3339
LottoNumber bonusNumber = new LottoNumber(7);
@@ -45,17 +51,9 @@ public class DrawExecutorTest {
4551

4652
@Test
4753
void 보너스_번호는_당첨번호와_중복될_수_없다() {
48-
LottoRegistry registry = new LottoRegistry();
49-
5054
Lotto lotto = LottoFactory.createLotto(LottoType.AUTOMATIC);
5155
registry.add(lotto);
5256

53-
Set<LottoNumber> numbers = Set.of(
54-
new LottoNumber(1), new LottoNumber(2), new LottoNumber(3),
55-
new LottoNumber(4), new LottoNumber(5), new LottoNumber(6));
56-
57-
Lotto winningLotto = Lotto.of(numbers);
58-
5957
LottoNumber bonusNumber = new LottoNumber(6);
6058

6159
assertThatThrownBy(() -> {

0 commit comments

Comments
 (0)