소프트웨어 변경 시 LLM 기반 테스트 생성 성능 평가
Evaluating LLM-Based Test Generation Under Software Evolution
TL;DR Highlight
8개 LLM·22,374개 프로그램 변형 대규모 실험 — LLM 생성 테스트의 99% 이상이 원본 코드 패턴에 묶여 있어 코드 변경 후 급격히 열화됨
Who Should Read
LLM 자동 테스트 생성을 CI/CD에 도입하려는 개발자, AI 코딩 도구의 신뢰성을 평가하는 엔지니어
Core Mechanics
- 원본 코드 기준 라인 커버리지 79.2%, 브랜치 76.1% — 높은 기준선이지만 코드 변경 시 급락
- 의미 변경(SAC) 후: 통과율 66.5%(▼33.4pp), 브랜치 60.6%(▼15.5pp) — 실패 테스트의 99% 이상이 원본에서는 통과 (잔류 정렬 현상)
- 의미 보존 변경(SPC) 후에도: 통과율 78.9%(▼21pp) — 변경 없는데 구문 변화만으로도 열화; 구조적 노이즈에 민감
- Python이 Java보다 훨씬 어려움 — Gemini 2.5 Flash: Java 323번 vs Python 2155번 시도
- 회귀 인식 부재 — 테스트 suite 교체율 SAC 70%, SPC 82% (매칭률 각각 29%, 18%); 기존 고품질 테스트 버리고 낮은 품질로 재생성
- GPT-5 Mini(SAC 82.9%), Claude 4.6 Sonnet이 가장 탄력적. GPT-5.2는 고기준선에도 SAC 후 56.2%로 과적합 의심
Evidence
- 8개 LLM(GPT-5, GPT-5.2, Claude 4.5 Haiku, Claude 4.6 Sonnet, Gemini 2.5 Flash, Gemini 3.1 Pro, GPT-OSS, Nemotron-3-Nano), 22,374 변형, 346M 토큰 소비
- 5가지 SAC(경계이동·불리언·산술·인수교환·변수역할) + 9가지 SPC(중복 else·더미 루프·미사용 파라미터·오해 유발 변수명·만다린 주석 등) 체계적 적용
How to Apply
- LLM 생성 테스트를 회귀 테스트로 사용할 때는 코드 변경 후 무조건 재생성 + 기존 테스트와 비교 검증 필요
- 코드 diff와 변경 의도를 프롬프트에 명시하면 잔류 정렬 현상 완화 기대
- Python 프로젝트는 LLM 테스트 생성 신뢰도가 Java보다 낮음 — 수동 검증 비중 높여야
Terminology
Original Abstract (Expand)
Large Language Models (LLMs) are increasingly used for automated unit test generation. However, it remains unclear whether these tests reflect genuine reasoning about program behavior or simply reproduce superficial patterns learned during training. If the latter dominates, LLM-generated tests may exhibit weaknesses such as reduced coverage, missed regressions, and undetected faults. Understanding how LLMs generate tests and how those tests respond to code evolution is therefore essential. We present a large-scale empirical study of LLM-based test generation under program changes. Using an automated mutation-driven framework, we analyze how generated tests react to semantic-altering changes (SAC) and semantic-preserving changes (SPC) across eight LLMs and 22,374 program variants. LLMs achieve strong baseline results, reaching 79% line coverage and 76% branch coverage with fully passing test suites on the original programs. However, performance degrades as programs evolve. Under SACs, the pass rate of newly generated tests drops to 66%, and branch coverage declines to 60%. More than 99% of failing SAC tests pass on the original program while executing the modified region, indicating residual alignment with the original behavior rather than adaptation to updated semantics. Performance also declines under SPCs despite unchanged functionality: pass rates fall to 79% and branch coverage to 69%. Although SPC edits preserve semantics, they often introduce larger syntactic changes, leading to instability in generated test suites. Models generate more new tests while discarding many baseline tests, suggesting sensitivity to lexical changes rather than true semantic impact. Overall, our results indicate that current LLM-based test generation relies heavily on surface-level cues and struggles to maintain regression awareness as programs evolve.