C2カバレッジが複合条件網羅(MCC)かどうか
#🌿
C2カバレッジが複合条件カバレッジ(multiple condition coverage; MCC)であるとするものが出てきてしまったので真偽を調べる
MCCをC2カバレッジとしている例
カバレッジとは?ソフトウェア分野における基準や計測方法を解説|ソフトウェアテストのSHIFT. 2023-11-01
コードカバレッジ 7つの種類とコード例を紹介!知っておくべき落とし穴| Qbook. 2025-01-30
自分が今まで出会ってきた定義はC2カバレッジは条件網羅だった。MCCというのは初耳だった。
テストに関わることであるため、ISTQBの用語集を調べる。
ISTQB Glossaryによる条件網羅(条件カバレッジ)定義
テストスイートが遂行した条件結果のパーセンテージ。条件カバレッジを100%にするには、各判定ステートメントの全ての単一条件に対し、真と偽をテストする必要がある。
ref: 条件カバレッジ(condition coverage) - ISTQB Glossary https://glossary.istqb.org/ja_JP/term/condition-coverage
if (A && B) {...}
A && Bはステートメント、判断文
A, Bは単一条件(単純条件)
これはテストケースに寄るが、下記の2パターンがある。
(1) (T, F), (F, T)
(2) (T, T), (F, F)
(1), (2)の組合せですべての単一条件(A, B)に対して真、偽の両方をテストしているため、条件カバレッジが100%を達成している。
A && Bの真理値表も念のため書いておく。
$ \begin{array}{c|c|c} A & B & A\ \&\&\ B \\ \hline \colorbox{#fcc}{T} & \colorbox{#fcc}{T} & \colorbox{#fcc}{T} \\ \colorbox{#fcc}{T} & F & F \\ F & \colorbox{#fcc}{T} & F \\ F & F & F \end{array}
ISTQB Glossaryによる複合条件カバレッジ(MCC)の定義
テストスイートが遂行した一つのステートメントの中にある全ての単一条件結果の組み合わせのパーセンテージ。100%の複合条件カバレッジは、100%の改良条件判定カバレッジを意味する。
ref: 複合条件カバレッジ(multiple condition coverage) - ISTQB Glossary https://glossary.istqb.org/ja_JP/term/multiple-condition-coverage?term=複合条件&exact_matches_first=true
複合条件カバレッジ(MCC)は、「全ての単一条件結果の組み合わせのパーセンテージ」と言っているので(T, T), (T, F), (F, T), (F, F)の4種類を要求しているように見える。
Most professional software developers use C1 and C2 coverage. C1 stands for statement coverage and C2 for branch or condition coverage.
ref: Code coverage - Wikipedia
↓
ほとんどのプロフェッショナルなソフトウェア開発者はC1カバレッジとC2カバレッジを使用します。C1はステートメントカバレッジを、C2は分岐カバレッジまたは条件カバレッジを表します。
テストカバレッジ基準の歴史(1): A Lifelong Software Tester (生涯一テスター)
テクマトリックス社はC2は条件網羅の立場
C2カバレッジは、条件網羅率であり、コード内のすべての条件を少なくとも1回は実行されているかどうかを計測します。
ref: C2カバレッジ | 静的解析ツール・単体テストツール C/C++test | テクマトリックス株式会社
Decision Coverage
This metric reports whether Boolean expressions tested in control structures (such as the if-statement and while-statement) evaluated to both true and false. The entire Boolean expression is considered one true-or-false predicate regardless of whether it contains logical-and or logical-or operators. Additionally, this metric includes coverage of switch-statement cases, exception handlers, and all points of entry and exit. Constant expressions controlling the flow are ignored.
The term branch coverage is equivalent to decision coverage, although it is sometimes described differently. Branch coverage requires that all branches be taken, both condition and unconditional. However, if all conditional branches have been taken, then all reachable unconditional branches must also have been taken.
Also known as: all-edges coverage Roper1994 p.58, C2 Beizer1990 p.75, decision-decision-path testing Roper1994 p.39. I discourage using the non-descriptive name C2 because of the confusion with the term C1.
ref: Steve Cornett. Code Coverage Analysis.
↓
判断文カバレッジ
この指標は、制御構造(if文やwhile文など)でテストされた論理式が、真と偽の両方の値を取ったかどうかを報告します。論理式全体は、論理積演算子(AND)や論理和演算子(OR)の有無にかかわらず、単一の真偽判定条件として扱われます。さらに、この指標ではswitch文のcase分岐、例外処理ブロック、およびすべてのエントリポイント/エグジットポイントのカバレッジも含まれます。フロー制御を行う定数式は考慮されません。
「分岐カバレッジ」という用語は判断文カバレッジと同義ですが、場合によっては異なる表現が用いられることもあります。分岐カバレッジでは、条件分岐と無条件分岐の両方をすべて実行することが要求されます。ただし、すべての条件分岐が実行されている場合、到達可能な無条件分岐もすべて実行されている必要があります。
別名:全エッジカバレッジ Roper1994 p.58、C2 Beizer1990 p.75、決定-決定パステスト Roper1994 p.39。「C2」という表現は、C1という用語との混同を招くため、私は使用を推奨しません。
Ntafos1988 "A Comparison of Some Structural Testing Strategies", Simeon Ntafos, IEEE Trans. Software Eng., Vol.14, No.6, June 1988, pp.868-874.
Beizer1990 "Software Testing Techniques", 2nd edition, Boris Beizer, New York: Van Nostrand Reinhold, 1990
Roper1994 Marc Roper, "Software Testing", London, McGraw-Hill Book Company, 1994
1975: C0, C1, C2, … Miller
(1975-1977) C0 : Programmer‘s intuition, C1 : Every statement in a program exercised at least once, C2 : Every program predicate outcome exercised at least once, ...
E. Miller, The Art and the Theory of Program Testing, 1975
(1977-) C0 : Every statement executed at least once, C1 : Every segment executed at least once, C1 p : Every predicate term executed for each outcome, C2 : C1 + interior and boundary tests for each iteration, ...
E. Miller, Coverage levels, in "Infotech State of the Art Report: Software Testing," Vol. 1, 1979
ref: Keizo Tatsumi. How to Learn The History of Software Testing, P28.
↓
(1975-1977年)C0:プログラマの直感に基づくテスト、C1:プログラム中の各ステートメントが少なくとも1回は実行されること、C2:プログラム中の各述語結果が少なくとも1回は検証されること、...
E. ミラー『プログラムテストの技法と理論』1975年
(1977年以降)C0:各ステートメントが少なくとも1回は実行されること、C1:各セグメントが少なくとも1回は実行されること、C1 p:各述語項がそれぞれの結果に対して実行されること、C2:C1に加え、各反復処理における内部テストと境界値テストを実施すること、...
E. ミラー「『インフォテック・ステート・オブ・ザ・アート報告書:ソフトウェアテスト』第1巻」1979年におけるカバレッジレベルの定義
1975-1977年までのC2カバレッジの定義
1977年以降のC2カバレッジの定義
C1 + ループの内部/境界テスト
MCCとしている例
調べるきっかけとなった下2リンク
カバレッジとは?ソフトウェア分野における基準や計測方法を解説|ソフトウェアテストのSHIFT. 2023-11-01
コードカバレッジ 7つの種類とコード例を紹介!知っておくべき落とし穴| Qbook. 2025-01-30
GAIO TechnologyのCoverageMasterという製品に記載されているPDFの記述。
However, when all combinations of condition logic are taken into account in condition coverage (C2), some invalid test cases occur among these combinations. For example, if the logic of (X and Y) in the compound condition shown above is TRUE, the overall logic of the (X and Y) or Z condition is determined at this point to be TRUE, regardless of the logic of Z. This means that
there is no point in testing both of the two logic combinations at the right end of the logic table shown above (the logic enclosed in the green box). Only one of the two needs to be tested. MC/DC (Modified Condition/Decision Coverage) functions as a method of examining each condition and confirming the effect of changes in the logic instead of using superfluous combinations of logic that occur in condition coverage (C2).
ref: CoverageMaster winAMS Tutorial. P103. https://www.gaio.co.jp/support/user/pdf/CoverageMaster_Tutorial_EN_v2.1.0.pdf
↓
しかしながら、条件論理のすべての組み合わせを条件網羅率(C2)の評価対象とした場合、これらの組み合わせの中に無効なテストケースが生じることがある。例えば、前述の複合条件における「(XかつY)」の論理がTRUEである場合、この時点で「(XかつY)またはZ」という条件全体の論理はZの論理内容にかかわらず自動的にTRUEと判定される。つまり、
> 上記の論理表の右側端部にある2つの論理組み合わせ(緑色のボックスで囲まれた部分)について、両方をテストする必要はない。どちらか一方のみをテストすれば十分である。MC/DC(修正条件/決定網羅)は、条件網羅率(C2)で生じる不要な論理組み合わせを使用する代わりに、各条件を個別に検証し、その論理変更の影響を確認する手法として機能する。
ホワイトボックス・テストの“永遠の王様”-パス網羅-
パス網羅をざっくりと分類すると、以下の4種類になります。
・C0:命令語網羅(全命令語を1回は実行)
・C1:分岐網羅(条件文の真と偽を実行)
・C2:複合条件網羅(真偽の組み合わせを実行)
:
:
・C∞:全パス網羅(すべての可能なパスを実行)
ref: 山浦 恒央. 開発するのに30分、テストするのに10万年:山浦恒央の“くみこみ”な話(13) - MONOist. 2009-11-20
結論
調べても曖昧なので使わないほうが良さそう
関連
テストカバレッジの歴史
パスカバレッジ
参考
条件カバレッジ(condition coverage) - ISTQB Glossary
複合条件カバレッジ(multiple condition coverage) - ISTQB Glossary
Code coverage - Wikipedia
C2カバレッジ | 静的解析ツール・単体テストツール C/C++test | テクマトリックス株式会社
CoverageMaster winAMS Tutorial. P103. https://www.gaio.co.jp/support/user/pdf/CoverageMaster_Tutorial_EN_v2.1.0.pdf
テストカバレッジ基準の歴史(1). A Lifelong Software Tester (生涯一テスター). 2011-12-31
How to Learn The History of Software Testing | PDF
Code Coverage Analysis
メモ
Whats my Coverage? (C0 C1 C2 C3 + Path). Michael Grosser, the Blog. 2008-04-04
テスト・カバレッジ(テスト網羅率)_テストカバレッジ. CSDN博客. 2009-11-23
dtinth/01219343: Project work for 01219343 Software Testing. 最新2014-02-03コミット
カバレッジの種類~C0・C1・C2・MCC~ - NRIネットコムBlog. 2023-12-01
分岐カバレッジ(C1/C2)とgcovのカバレッジの違い #ソフトウェア品質 - Qiita. 更新日2023-12-11, 投稿日2023-12-03
【コード解説付き】C0 / C1 / C2カバレッジとは?初心者でも分かるソフトウェアテストの基礎 - ソフトウェアテスト代行サービス『テスター10』. 更新日2025-12-23, 投稿日2025-11-18
Testing and Code Coverage