forked from next-step/java-racingcar-playground
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCarTest.java
More file actions
39 lines (33 loc) · 1.16 KB
/
CarTest.java
File metadata and controls
39 lines (33 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import game.Car;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import static org.junit.jupiter.api.Assertions.*;
class CarTest {
@Test
@DisplayName("자동차 이름은 5자를 넘을수 없음")
void carNameLength_IsExceed_Then_Exception() {
assertThrows(IllegalArgumentException.class, () -> {
inputCarName("aaaaaaaa");
});
}
@ParameterizedTest
@ValueSource(strings = {" ","","a, b, c"})
@DisplayName("자동차 이름은 공백이 포함될수 없음")
void carName_isEmptyOrNull_Then_Exception(String carName) {
assertThrows(IllegalArgumentException.class, () -> {
inputCarName(carName);
});
}
@Test
@DisplayName("자동차 이름엔 특수문자가 들어갈수 없음")
void carName_Include_SpecialCharacters_Then_Exception() {
assertThrows(IllegalArgumentException.class, () ->{
inputCarName("!@#$");
});
}
private void inputCarName(String carName) {
Car car = new Car(carName);
}
}