33 lines
2.0 KiB
Markdown
33 lines
2.0 KiB
Markdown
---
|
|
title: ArchUnit violations-as-data 패턴 면접 질문
|
|
source_type: interview
|
|
status: raw
|
|
related_branch: feature-streaming-response-contract
|
|
tags: [archunit, violations-as-data, testing, clean-architecture, interview]
|
|
created: 2026-06-02
|
|
---
|
|
|
|
# ArchUnit violations-as-data 패턴 면접 질문
|
|
|
|
## Parent
|
|
|
|
- [[raw/branch-notes/feature-streaming-response-contract]]
|
|
|
|
## 질문 목록
|
|
|
|
**Q1.** ArchUnit 에서 `@AnalyzeClasses(importOptions = DoNotIncludeTests.class)` 를 사용하는 이유는?
|
|
|
|
> 핵심: production code 만 스캔 대상으로 한정. test fixtures 가 의도적으로 규칙을 위반하더라도 production 아키텍처 테스트가 실패하지 않도록.
|
|
|
|
**Q2.** "vacuous pass" 문제가 무엇이며 violations-as-data 패턴이 어떻게 해결하는가?
|
|
|
|
> ArchUnit rule 이 production code 에서 아무것도 매칭하지 못할 때 `allowEmptyShould(true)` 없으면 예외, 있으면 통과. 통과 여부가 "규칙이 실제로 위반을 잡는가" 와 무관 → vacuous pass. violations-as-data: 의도적 위반 fixture 에 대해 `rule.evaluate(fixtures).hasViolation() == true` 를 별도로 단언.
|
|
|
|
**Q3.** `testCompileOnly` 로 선언된 타입을 ArchUnit 위반 fixture 에서 참조할 때 주의사항은?
|
|
|
|
> `testCompileOnly` 는 compile-time 전용이라 test execution runtime classpath 에 없음. JUnit 이 fixture class 를 로드할 때 superclass/interface 를 즉시 resolve → `NoClassDefFoundError`. annotation 참조는 lazy-resolve 이므로 안전. 따라서 forbidden type 이 `testCompileOnly` 라면 **annotation 으로만** 참조.
|
|
|
|
**Q4.** over-block guard test 가 필요한 이유는? 예시를 들어 설명하라.
|
|
|
|
> "차단하지 말아야 할 것을 차단하지 않는다" 를 검증. 예: `no_response_body_emitter` 는 `ResponseBodyEmitter` 를 차단하되 `StreamingResponseBody` 는 차단하지 않아야 함. `ALLOWED_STREAMING_CLASSES` 에서 `hasViolation() == false` 를 단언 → 규칙 경계가 의도대로임을 보장.
|