iOS 응용 (swift)
[iOS - Swift] 4. Build Setting 개념 - ENABLE_TESTABILITY, Enable Testability, @testable import
jake-kim
2022. 12. 20. 23:22
ENABLE_TESTABILITY
- 해당 Target의 Enable Testablility를 활성화하면 테스트하는 쪽에서 @testable import를 사용하여 internal인 타겟도 테스트 코드에서 접근이 가능

- Xcode에서는 Target > Build Settings > ENABLE_TESTABILITY에서 Yes로 활성화
- Debug는 디폴타 값이 Yes

예시
- ViewController는 internal 키워드이므로 다른 모듈에서 접근이 불가

- ExTestableTests는 ViewController이 있는 모듈이 아니지만 @testable import ExTestable를 통해 사용

- 만약 Debug를 No로 설정하면?

- 접근 불가

* 참고
https://stackoverflow.com/questions/46798225/whats-happening-behind-the-scenes-in-xctests-testable