You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[동기화 (synchronized) 명시 vs Java 제공 동시성 라이브러리](#concurrency-sync-vs-map)
48
48
-[동기화 (synchronized) 명시 vs Atomic 변수 vs @volatile](#concurrency-sync-vs-atomic)
49
49
-[Private 변수](#concurrency-private-this)
50
50
-[동시성 로직 분리](#concurrency-isolation)
51
-
4.[성능](#perf)
51
+
1.[성능](#perf)
52
52
-[Microbenchmarks](#perf-microbenchmarks)
53
53
-[순회와 zipWithIndex](#perf-whileloops)
54
54
-[Option과 null](#perf-option)
55
55
-[Scala Collection 라이브러리](#perf-collection)
56
56
-[private[this]](#perf-private)
57
-
5.[Java 호환성](#java)
57
+
1.[Java 호환성](#java)
58
58
-[Scala에서 사용 할 수 없는 Java 기능](#java-missing-features)
59
59
-[Traits와 Abstract 클래스](#java-traits)
60
60
-[Type 별칭](#java-type-alias)
@@ -63,7 +63,9 @@ Scala는 매우 강력하며 여러가지 페러다임에 적용 가능한 언
63
63
-[가변인자](#java-varargs)
64
64
-[Implicits](#java-implicits)
65
65
-[관련 객체, 정적 함수 및 변수](#java-companion-object)
66
-
6.[기타](#misc)
66
+
1.[테스트](#testing)
67
+
-[예외 가로 채기](#testing-intercepting)
68
+
1.[기타](#misc)
67
69
-[currentTimeMillis 보다는 nanoTime](#misc_currentTimeMillis_vs_nanoTime)
68
70
-[URL 보다는 URI](#misc_uri_url)
69
71
@@ -78,6 +80,7 @@ Scala는 매우 강력하며 여러가지 페러다임에 적용 가능한 언
78
80
- 2015-12-14: 이 가이드라인이 [한국어로 번역되었습니다](README-KO.md). 한국어 번역은 [Hyukjin Kwon](https://github.com/HyukjinKwon) 이 했으며, [Yun Park](https://github.com/yunpark93), [Kevin (Sangwoo) Kim](https://github.com/swkimme), [Hyunje Jo](https://github.com/RetrieverJo) 그리고 [Woocheol Choi](https://github.com/socialpercon) 가 검토를 했습니다. 이 문서의 최신성을 보장하지 않습니다.
79
81
- 2016-06-15: [익명 함수](#anonymous) 섹션 추가.
80
82
- 2016-06-21: [변수 명명 규칙](#variable-naming) 섹션 추가.
83
+
- 2017-02-23: [테스트](#testing) 섹션 추가.
81
84
82
85
83
86
## <aname='syntactic'>구문 스타일</a>
@@ -1082,6 +1085,25 @@ class JavaFriendlyAPI {
1082
1085
caseobjectMyClassextendsMyClass
1083
1086
```
1084
1087
1088
+
## <aname='testing'>테스트</a>
1089
+
1090
+
### <aname='testing-intercepting'>예외 가로 채기</a>
1091
+
1092
+
특정한 예외를 발생 시키는 행동을 테스트 할 때는 (예를 들어, 잘못된 인자를 주어 함수를 호출 하는 것), 가능한 한 예외의 타입을 구체적으로 명시 하도록 합니다. (ScalaTest를 사용하는 경우) 단순히 `intercept[Exception]` 이나 `intercept[Throwable]` 을 해서는 안됩니다. 왜냐하면, 이 것은 _모든_ 타입의 예외가 발생 했다는 것을 체크하기 때문입니다. 이 경우, 만들어진 테스트들은 오류가 발생했다는 것만 확인 하고, 실제 확인해야 하는 행동을 확인하지 않은채 조용히 통과 할 것 입니다.
1093
+
1094
+
```scala
1095
+
// 잘못된 경우
1096
+
intercept[Exception] {
1097
+
thingThatThrowsException()
1098
+
}
1099
+
1100
+
// 올바른 경우
1101
+
intercept[MySpecificTypeOfException] {
1102
+
thingThatThrowsException()
1103
+
}
1104
+
```
1105
+
1106
+
만약 예외의 타입이 구체적으로 명시 될 수 없다면, 코드 스멜의 징후일 수 있습니다. 낮은 레벨의 테스트를 하거나 구체적인 타입의 예외를 발생시키도록 해당 코드를 수정 해야 합니다.
0 commit comments