Documentation
MC/DC
Check whether tests exercise each part of a decision independently.
MC/DC stands for Modified Condition/Decision Coverage. It checks whether your tests show each part of a decision changing the outcome independently.
For checkout that requires a signed-in customer and an unexpired session, testing “allowed” and “denied” isn’t enough to show that both requirements work. Your tests may never check what happens when the session expires.
Use it with your agent
Supercov reports MC/DC alongside line and branch coverage. There is no separate mapping step for it. Ask your agent to inspect an uncovered condition and add a test for the behavior it represents.
Run the full test suite with npx supercov. Inspect the MC/DC gaps and
add one test for a useful missing case. Only change tests. Rerun the
same suite and show what the new test checks and how coverage changed.Check MC/DC yourself
Run your tests through Supercov, then read the summary. Replace the example test command with the one you normally use:
npx supercov -- npm test
npx supercov runs latest
In this checkout example, two tests cover a valid order and a signed-out visitor. The recorded coverage section is:
Coverage
Lines 100.00% (5/5)
Branches 100.00% (2/2)
MC/DC 50.00% (1/2)
Lines and branches are covered, but one of the two conditions is missing. List the gaps, then inspect the decision at its file and line:
npx supercov runs latest gaps --limit 5
npx supercov runs latest decision src/session.js:2
The decision report shows:
cf8decfeb68a3191 src/session.js:2:7
signedIn && !expired
C1 covered: signedIn
C2 MISSING: !expired
confidence executed
vectors:
F- -> F tests=1 confidence=executed
TT -> T tests=1 confidence=executed
showing 1-2 of 2 conditions/vectors/tests per decision
C2 MISSING is the expiry check. Neither test shows that an expired session
changes the result for a signed-in customer. That’s the next case to test.
The vectors record what happened during execution: T is true, F is false,
and - means a condition wasn’t evaluated because an earlier condition
short-circuited the decision. MC/DC looks for two tests that show one
condition changing the decision’s outcome independently.
You can also use npx supercov runs latest file src/session.js
to read the gaps alongside the source. The
full recordings include the
source, tests and results for each selected language.
Example
Here’s a recorded Codex run in a JavaScript project. The example stays in JavaScript when you switch languages; the prompt above follows your selection.
src/session.js
allows checkout only when the customer is signed in and their session has
not expired:
export function canCheckout(signedIn, expired) {
if (signedIn && !expired) return true;
return false;
}
The two tests in
tests/session.test.js
check a valid session and a signed-out visitor:
assert.equal(canCheckout(true, false), true);
assert.equal(canCheckout(false, false), false);
The agent ran npx supercov -- npm test. Both tests passed. The summary
from npx supercov runs latest showed:
Coverage
Lines 100.00% (3/3)
Branches 100.00% (2/2)
MC/DC 50.00% (1/2)
Both return paths had run, but neither test checked an expired session. The agent inspected the file with:
npx supercov runs latest file src/session.js
The output identified the missing condition:
LINE STATUS SOURCE
2 PARTIAL signedIn && !expired
Unobserved: no witness pair shows `!expired` independently changing the decision result
The agent added one test, leaving the application code and existing tests unchanged:
test('a signed-in visitor with an expired session cannot check out', () => {
assert.equal(canCheckout(true, true), false);
});
It reran the same full suite. All three tests passed, and MC/DC reached 100%.
The comparison from npx supercov diff <before-run-id> latest showed:
lines +0pp, branches +0pp, MC/DC +50pp
gained: 0 lines, 0 branches, 1 MC/DC conditions
lost: 0 lines, 0 branches, 0 MC/DC conditions
+ MC/DC src/session.js:2 C2 !expired
The new test checks that an expired session prevents checkout. Removing the expiry check makes this test fail; the original two tests still pass.
To try these files, download the starter,
extract it, open the supercov-tutorial folder in your agent and run npm ci.
Then use the JavaScript prompt above. The completed test is not included in the
download. The recorded run
includes the commands, full output and completed test.
What it doesn’t tell you
MC/DC doesn’t test every combination of inputs or prove that the expected outcome is correct. Some combinations may be unreachable, and Supercov may report limits in what it can measure. Have the agent explain those cases instead of forcing the score to 100%.
It also doesn’t tell you whether tests check returned values or side effects. That’s the question assertion coverage helps investigate.
Read more in the terminal
npx supercov docs coverage-model
npx supercov runs latest decision --help
The installed coverage guide includes MC/DC; there isn’t a separate mcdc
topic in the CLI. docs prints the guide, while runs queries your recorded
tests. Neither command starts another test run.