# 같은 가정으로 만든 테스트는 같은 오류를 반복한다

> Property, contract, metamorphic, differential test와 hermetic fixture

- Canonical: https://learning.reopt.ai/en/courses/ai-code-quality/lessons/cq-m2-concept
- Language: en
- HTML: https://learning.reopt.ai/en/courses/ai-code-quality/lessons/cq-m2-concept

---

[AI code quality, verification & debugging](/en/courses/ai-code-quality) 2. 독립된 Test Oracle 3 / 9

# 같은 가정으로 만든 테스트는 같은 오류를 반복한다

Property, contract, metamorphic, differential test와 hermetic fixture
Concept 45 XP 9 min

AI에게 코드와 테스트를 동시에 맡기면 구현의 오해가 expected value에도 복제될 수 있습니다. 도메인 불변식, consumer contract, 입력 변환 전후 관계, 신뢰할 reference implementation을 이용해 독립된 oracle을 만듭니다.
확률적 내부보다 결정적 외부 경계 모델 문장 자체를 고정하지 말고 schema, citation, authorization, allowed action, state transition을 검증합니다. 시간·random·network·identity·data는 fixture로 통제하고 모델 응답은 record·stub·adversarial set으로 재현합니다.

| Oracle | 검증 대상 | 예시 |
| Property | 항상 지켜야 할 불변식 | 권한 밖 data 0건 |
| Contract | consumer·provider 경계 | schema·error·version |
| Metamorphic | 입력 변환과 출력 관계 | 순서 변경에도 합계 동일 |
| Differential | 독립 구현과 비교 | 구/신 계산 결과 대조 |

- 1 불변식 추출 Domain·security·data·state에서 항상 참이어야 할 속성을 적습니다.

- 2 Oracle 분리 구현 코드와 다른 source·관점·작성자로 expected를 만듭니다.

- 3 Fixture 통제 Clock·random·network·identity·model response를 결정적으로 고정합니다.

- 4 Adversarial 확장 경계값·malformed·injection·중복·순서 역전 case를 추가합니다.

실무에 남길 기준

- Snapshot이 많아도 의미 있는 oracle이 없으면 회귀를 설명하지 못한다
- 모델 출력은 문자열보다 schema·근거·권한·행동 결과로 평가한다
- Fixture의 결정성은 flaky test 감소뿐 아니라 실패 재현의 기반이다

[Previous](/en/courses/ai-code-quality/lessons/cq-m1-quiz) Got it · Continue

---

Site guide for agents: https://learning.reopt.ai/llms.txt · Sitemap: https://learning.reopt.ai/sitemap.xml · Contact: https://learning.reopt.ai/contact
