프로젝트

일반

사용자정보

구조 기반 테스트 케이스 설계 사례

Prof. Jong Min Lee이(가) 10일 전에 추가함

if (weight > 10 and color in ('red', 'green', 'blue')) 테스트 케이스 설계

1. Branch Testing (분기 커버리지)

전체 조건식의 True/False 분기만 테스트합니다.

테스트 케이스 weight color 결과 설명
TC-1 15 red T 전체 조건식 True 분기
TC-2 5 red F 전체 조건식 False 분기

2. Condition Testing (조건 커버리지)

개별 조건(weight >10, color in 리스트)의 True/False를 모두 테스트합니다.

테스트 케이스 weight color 결과 검증 조건
TC-3 15 red T weight=T, color=T
TC-4 5 yellow F weight=F, color=F

3. Branch-Condition Combination Testing (분기-조건 조합 커버리지)

모든 조건 조합(2x2=4)을 테스트합니다.

테스트 케이스 weight color 결과 조합
TC-5 15 red T weight=T, color=T
TC-6 15 yellow F weight=T, color=F
TC-7 5 red F weight=F, color=T
TC-8 5 yellow F weight=F, color=F

4. MC/DC Testing (수정 조건/결정 커버리지)

각 조건이 독립적으로 결과에 영향을 미치는지 검증합니다.

(n+1 = 2+1 = 3개 테스트 케이스)

테스트 케이스 weight color 결과 독립성 검증 대상
TC-9 15 red T 기준 테스트
TC-10 5 red F weight 독립성
TC-11 15 yellow F color 독립성

테스트 케이스 상세 설명

  • TC-9 → TC-10: weight=F로 변경 → 결과 T→F (weight가 결정에 독립적 영향)
  • TC-9 → TC-11: color=F로 변경 → 결과 T→F (color가 결정에 독립적 영향)

MC/DC 검증 로직

- weight=F (TC-10): (False AND True) → False

- color=F (TC-11): (True AND False) → False

- 두 변경 모두 전체 결과를 T→F로 변경시켜 독립성 입증

Citations:
[1] https://stackoverflow.com/questions/54155711/test-coverage-for-many-and-or-conditions-in-one-statement
[2] https://www.automatetheplanet.com/types-of-code-coverage-examples-in-c/
[3] https://maskray.me/blog/2024-01-28-mc-dc-and-compiler-implementations
[4] https://blog.kotlin-academy.com/write-tests-for-all-your-missed-branches-3c74459ed512
[5] https://www.parasoft.com/blog/measuring-code-coverage/
[6] https://softwareengineering.stackexchange.com/questions/155880/unit-testing-multiple-conditions-in-an-if-statement
[7] https://blog.naver.com/jackhwang0210/222091625840
[8] https://jsdysw.tistory.com/389
[9] https://support.smartbear.com/testcomplete/docs/keyword-testing/reference/statements/if-then.html
[10] https://gist.github.com/26cff55b09e24ce47725b945e2e4149d


Perplexity로부터의 답변: pplx.ai/share