Files
llm-wiki/raw/interviews/archunit-violations-as-data-pattern-2026-06-02.md

2.0 KiB

title, source_type, status, related_branch, tags, created
title source_type status related_branch tags created
ArchUnit violations-as-data 패턴 면접 질문 interview raw feature-streaming-response-contract
archunit
violations-as-data
testing
clean-architecture
interview
2026-06-02

ArchUnit violations-as-data 패턴 면접 질문

Parent

질문 목록

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_emitterResponseBodyEmitter 를 차단하되 StreamingResponseBody 는 차단하지 않아야 함. ALLOWED_STREAMING_CLASSES 에서 hasViolation() == false 를 단언 → 규칙 경계가 의도대로임을 보장.