About

9.2 Review: Completion Criteria, Decision Tables & MC/DC

Theory: Completion Criteria, Decision Tables & MC/DC

Before a long trip you do not reread the whole guidebook; you check the three routes you are most likely to take. In the review class the professor did exactly that and re-taught three topics with full worked examples: test completion criteria, cause-effect graphs with decision tables, and MC/DC. This page condenses those three, with the reason behind every step, then gives a map of the whole course and a rapid-reference sheet. The full lessons are 7.1–7.3, 6.3–6.4, and 3.5 with Lecture 4.

A. Test Completion Criteria (see 7.1–7.3)

The bug curve rises quickly, flattens, and never reaches the top (2.5). If you test until you “find everything”, you never stop. So a project fixes, before testing starts, a rule that says when testing is complete: the test completion criterion. The two rules everyone is tempted by are both bad: “stop when time runs out” (you could do nothing and still finish) and “stop when all tests pass” (it rewards easy tests that find nothing).

CategoryStop when…Works bestWeakness
1. Principles & coveragethe planned coverage is reached, e.g. all MC/DC tests rununit and module tests, where you can see the codeusually not applicable at system or acceptance level, where there are only guidelines, not exact methods
2. Past statisticsthe number of errors predicted from old projects has been foundorganisations with historyprior work must be done first; without old data the number cannot be trusted
3. Bug-finding trendthe slope of this project’s bug curve shows its greatest dropany project, no history neededthe current project must be monitored closely, interval by interval

Category 2: the chain of the 10,000-statement example

Read the calculation as a chain where each link answers one “why”:

  1. Total errors. 10,000 statements at about 5 errors per 100 statements: 10,000×5/100=50010{,}000 \times 5 / 100 = 500.
  2. Kinds of error. The industry study in the slides: about 40% CLD (coding and logic design, small mistakes inside the code) and 60% design. So CLD =200= 200, design =300= 300. If the split is not given in the question, write it as your assumption.
  3. Goals. Never 100% (unattainable perfection): 98% of CLD =196= 196, 95% of design =285= 285.
  4. Share per level (from past projects), then target per level:
Test levelCLD foundDesign foundStopping target
Module65%0%0.65×200+0×300=1300.65 \times 200 + 0 \times 300 = 130
Function30%60%0.30×200+0.60×300=60+180=2400.30 \times 200 + 0.60 \times 300 = 60 + 180 = 240
System3%35%0.03×200+0.35×300=6+105=1110.03 \times 200 + 0.35 \times 300 = 6 + 105 = 111
Total98%95%130+240+111=481=196+285130 + 240 + 111 = 481 = 196 + 285 ✓

The module test finds 0% of design errors because a module test looks at one small unit; it is too low-level to see a design mistake. The columns add up to exactly the goals (98% and 95%), which is the check that the split is consistent.

Exam radar: “65% of what?” The professor asked this in class. It is 65% of the total CLD errors (200), not of all 500 errors, and not of the goal 196. Each design percentage is of the total design errors (300). In practice: stop the module test after finding 130 errors.

Category 3: the slope rule

Plot time (equal units, e.g. weeks) on the x-axis and the cumulative number of bugs found on the y-axis. The slope of each interval is the number of bugs found in that interval:

S=n2−n1t2−t1S = \frac{n_2 - n_1}{t_2 - t_1}

A high slope is good news: testing is paying off. The slope shrinks towards zero, but waiting for zero takes too long, so the rule is: stop at the greatest drop in the slope. Compute every slope, then each slope minus the one before it, and find the most negative difference.

Week0123456
Cumulative bugs04085120135142146
Slope of the interval ending here–4045351574
Difference from previous slope––+5−10−20−8−3

The greatest drop is 15−35=−2015 - 35 = -20, in the interval ending at week 4, so stop at week 4. If this comes in the exam the numbers are given; show every slope, every difference, and name the greatest drop clearly.

B. From Words to a Decision Table: dateFashion (see 6.3–6.4)

The specification: you and your date want a table at a restaurant. Each has a style from 0 to 10. If either of you has style 8 or more, the answer is 2 (yes), with the exception that if either of you has style 2 or less, the answer is 0 (no). Otherwise the answer is 1 (maybe).

The professor’s most important tip: reading a cause-effect graph straight out of the words is hard. Turn the words into the simplest possible code first; the conditions of the if statements become the causes and the return values become the effects. Keep the code simple, because a decision table cannot handle complex statements well.

int dateFashion(int you, int date) {
    if (you <= 2 || date <= 2)       return 0;   // effect 70: no (the exception wins)
    else if (you >= 8 || date >= 8)  return 2;   // effect 72: yes
    else                             return 1;   // effect 71: maybe
}

The “2 or less” check comes first because “with the exception” means that rule beats everything, even a very stylish partner.

Now write the logic, remembering one rule: else = NOT of everything before it.

Diagram loads as you scroll.

To reach MAYBE you must pass two “no” answers, so the maybe rule needs both NOTs. With only the first NOT, (1 || 3)' && (2 || 4) is exactly the yes rule, so maybe and yes would collide.

Exam radar: the professor singled out this rule after the review class: maybe = (1 || 3)' && (2 || 4)', which means all four causes false. Dropping the second NOT is the classic slip, and a rule the professor goes out of the way to stress is a strong sign it will be tested.

In the graph, two OR nodes group the causes (1 with 3, 2 with 4); NOT lines lead from the “no” OR node into the AND nodes for yes and maybe, and a second NOT leads from the “8 or more” OR node into maybe.

Finally, the decision table. All entries in one rule (one column) are joined by AND, so an OR cannot fit in one column: every OR splits into separate rules. Conditions that do not matter in a rule get an X.

Condition / effectT1T2T3T4T5
1: you ≤ 21X000
2: you ≥ 8XX1X0
3: date ≤ 2X1000
4: date ≥ 8XXX10
70: no (0)11000
71: maybe (1)00001
72: yes (2)00110
Test (you, date) → expected(2, 5) → 0(5, 1) → 0(8, 5) → 2(5, 9) → 2(5, 5) → 1

The “no” OR becomes T1 and T2; the “yes” OR becomes T3 and T4; maybe is a single AND, so a single rule T5. The table gives the correct answer for every one of the 11×11=12111 \times 11 = 121 possible inputs.

C. MC/DC Once More (see 3.5 and Lecture 4)

The professor ended the review by saying that MC/DC can very often be expected in the exam.

Why it exists

Think of checking a team of guards by asking each one to do their job alone, while everyone else stands still. The cheap coverages (decision, condition, decision/condition) are fast but let bugs hide because of the short circuit: in A && B, if A is false Java never evaluates B, so a mistake in B stays invisible (A masks B). Multiple condition coverage fixes that by trying every combination, but that is 2n2^n tests and explodes. MC/DC is the sweet middle, the professor’s “optimal point between cost and strength”: for each condition it shows two tests that differ only in that condition and give different decisions. Since the other conditions stay fixed, nothing can hide, and it needs only about n+1n + 1 tests.

Exam radar: MC/DC requires each condition to be shown to independently affect the outcome of the decision. A minimum MC/DC test set has n+1n + 1 tests and can never be smaller. (2n2n is a known upper limit; the course focuses on n+1n + 1.)

The five steps, each with its reason

StepWhat you doWhy
1Truth table in the standard order: every column starts with F, the last variable changes every row.Answers use row numbers; with a different order your row 2 is not the professor’s row 2, and a correct answer looks wrong.
2Work out the result column; use masking to go faster (in X && (…), every row with X = F is F).You need the decision for every row before you can compare rows.
3Extended columns: in the A column compare rows that differ only in A; if the result changes, write each partner’s row number.This is the MC/DC rule itself, checked row by row.
4Mark the pairs with colours or shapes.The professor must see how you found them, or will not trust the answer.
5Choose rows: whole pairs only, at least one per column; start with the column with the fewest pairs, then follow the colour path to reuse rows until you reach n+1n + 1.The column with fewest pairs leaves no choice; overlapping rows keep the set minimal.

Checking a set someone gives you

Ask two questions in this order:

  1. Does every extended column contain a complete pair inside the set? If not, it is not an MC/DC test set, whatever its size.
  2. Does it have exactly n+1n + 1 rows? If yes, it is a minimum test set; if more, it is a test set but not minimum.

This was the trap in the past exam question (4.3): the given set had exactly n+1n + 1 rows, so it looked right, but one column had no pair. Pairs first, size second; the size alone never proves anything.

Quick reference: results to know

ExpressionPairsMinimum test set(s)Remember
A && BA {2,4}\{2,4\}; B {3,4}\{3,4\}{2,3,4}\{2,3,4\} = FT, TF, TTall true + each one false
A || BA {1,3}\{1,3\}; B {1,2}\{1,2\}{1,2,3}\{1,2,3\} = FF, FT, TFall false + each one true
A xor BA {1,3},{2,4}\{1,3\},\{2,4\}; B {1,2},{3,4}\{1,2\},\{3,4\}any 3 rows (4 answers)every extended cell is filled
A && (B || C)A {2,6},{3,7},{4,8}\{2,6\},\{3,7\},\{4,8\}; B {5,7}\{5,7\}; C {5,6}\{5,6\}{2,5,6,7}\{2,5,6,7\} or {3,5,6,7}\{3,5,6,7\}B and C force rows 5, 6, 7
(A && !B) || (C xor D)A {1,9},{4,12}\{1,9\},\{4,12\}; B {9,13},{12,16}\{9,13\},\{12,16\}; C and D six pairs eache.g. {1,9,13,14,15}\{1,9,13,14,15\} (16 minimum sets in all)past exam: the given set had no A pair

The Course Map

LectureWhat it taught
1Why we test: V&V, the STLC and the cost of late bugs, functional vs non-functional requirements, the 7 principles, the 5 bug definitions
2Why we cannot test everything: exhaustive testing, risk and testability, reading code, testing vs debugging, unattainable perfection, reviews
3Designing tests: static vs dynamic, Myers’ principles, black box vs white box, the coverage ladder, the MC/DC table method
4MC/DC practice: XOR and the colour path, checking a given set, the past exam question
5Testers and independence, equivalence partitioning, boundary value analysis, positive/negative tests
6The triangle, decision tables, cause-effect graphs, dateFashion, decision trees
7Test completion criteria (three categories), drivers and the MUT, IV&V
8Unit testing (failure vs error), harness/stubs/drivers, integration testing, TDD, JUnit, acceptance testing
9This review

If a topic is not on this map, it was not taught in CSC312.

Rapid Reference

Core formulas

PurposeFormula or rule
Independent combinationsMultiply the size of every independent input domain
Execution timeNumber of tests × time per test (then convert units carefully)
Risk (impact)How often it happens × how much it costs
Truth-table size2n2^n rows for nn Boolean conditions
MC/DC minimum targetn+1n + 1 tests, followed by pair verification
Boundary valuesAt, just below and just above each boundary
Category 2 stage targetCLD stage rate × CLD total + design stage rate × design total
Category 3 slopeChange in cumulative bugs ÷ change in time
Category 3 stopping pointThe largest negative difference between consecutive slopes

Final checks by question family

Question familyCheck before you hand in
Any test designEvery test case has inputs and an expected result.
Completion (Category 2)Every percentage is applied to the right total before multiplying.
Exhaustive testingEvery time calculation uses consistent units.
MC/DCEvery condition has a complete pair, not merely one selected row.
EP / BVAEvery test traces to a stated objective or partition.
Decision tableEvery X really means the condition cannot affect that rule’s action.
Decision treeEvery leaf corresponds to a reachable path.
Completion (Category 3)The conclusion uses the largest rate decrease, not the smallest final rate.
Written answersThe answer responds to the command word and ends with a direct conclusion (9.1).

Course-specific traps

TopicTrap to avoid
Verification and validationA faulty specification can pass verification; validation goes back to the user’s real needs.
Testing and debuggingTesting demonstrates a bug; debugging locates and fixes its cause.
Passing testsA pass shows only that the selected tests found no mismatch; it does not prove there are no bugs.
Decision and condition coverageNeither necessarily implies the other.
MC/DC countn+1n + 1 is a target, not a proof.
Load and stressLoad testing gives the system a large amount of work; stress testing pushes it beyond its normal limits, for example by restricting the resources it has to do that work.
Stubs and driversA stub is called by the unit under test; a driver calls the unit under test.
Category 3The greatest drop and the lowest rate are different calculations.
AcceptancePassing unit tests does not establish customer acceptance.

Common mistake: in a Category 3 question, picking the interval with the smallest slope. The rule asks for the greatest drop between neighbouring slopes, which usually comes earlier.


Worked Examples

Exercise 1

A program has 50,000 statements. About 3 errors per 100 statements remain after code inspection. The goal is to find 98% of the CLD errors and 95% of the design errors. Using the past-project shares from the course (module 65% CLD / 0% design, function 30% / 60%, system 3% / 35%), find the stopping criterion for the module, function and system tests. State explicitly your assumption(s).

Show solution ↓
Solution

Assumption: the industry split of the slides holds, 40% CLD errors and 60% design errors.

Step 1: total errors. 50,000×3/100=1,50050{,}000 \times 3 / 100 = 1{,}500.

Step 2: split. CLD =0.4×1,500=600= 0.4 \times 1{,}500 = 600; design =0.6×1,500=900= 0.6 \times 1{,}500 = 900.

Step 3: goals. 0.98×600=5880.98 \times 600 = 588 CLD errors; 0.95×900=8550.95 \times 900 = 855 design errors.

Step 4: targets per level (each percentage is of its own total, 600 or 900):

LevelCalculationTarget
Module0.65×600+0×9000.65 \times 600 + 0 \times 900390
Function0.30×600+0.60×900=180+5400.30 \times 600 + 0.60 \times 900 = 180 + 540720
System0.03×600+0.35×900=18+3150.03 \times 600 + 0.35 \times 900 = 18 + 315333

Check: 390+720+333=1,443=588+855390 + 720 + 333 = 1{,}443 = 588 + 855 ✓.

Stop the module test after finding 390 errors, the function test after 720, and the system test after 333.

Exercise 2

A program has 20,000 statements with about 3 errors per 100. This time the question states that half the errors are CLD errors and half are design errors. With the same goals (98% / 95%) and the same level shares, find the three stopping numbers. Then answer: a student computes the module target as 0.65×600=3900.65 \times 600 = 390. What went wrong?

Show solution ↓
Solution

The split is given, so use it instead of the 40/60 course assumption.

  • Total: 20,000×3/100=60020{,}000 \times 3 / 100 = 600. CLD =300= 300, design =300= 300.
  • Goals: 0.98×300=2940.98 \times 300 = 294; 0.95×300=2850.95 \times 300 = 285.
  • Module: 0.65×300+0=0.65 \times 300 + 0 = 195.
  • Function: 0.30×300+0.60×300=90+180=0.30 \times 300 + 0.60 \times 300 = 90 + 180 = 270.
  • System: 0.03×300+0.35×300=9+105=0.03 \times 300 + 0.35 \times 300 = 9 + 105 = 114.

Check: 195+270+114=579=294+285195 + 270 + 114 = 579 = 294 + 285 ✓.

The student answered “65% of what?” wrongly: 65% is a share of the CLD errors (300), not of all 600 errors. Applying it to the total also counts design errors, which a module test does not find at all.

Exercise 3

The cumulative numbers of bugs found at the end of weeks 0 to 7 are 0, 25, 60, 100, 130, 145, 152, 156. Using Category 3, when should testing stop? In which week is the bug-finding rate lowest, and why is that not the answer?

Show solution ↓
Solution

Slopes (bugs per week, S=Δn/ΔtS = \Delta n / \Delta t with Δt=1\Delta t = 1):

Interval0→11→22→33→44→55→66→7
Slope253540301574
Difference from previous–+10+5−10−15−8−3

The greatest drop is 15−30=−1515 - 30 = -15, in the interval ending at week 5. Stop at week 5.

The lowest rate is in the last interval (week 7, 4 bugs per week), but the rule asks where finding bugs slows down most sharply, the point of diminishing returns. The smallest slope only shows where the curve is flattest, and waiting for it means testing long past the point where the effort stopped paying off.

Exercise 4

Which category of test completion criterion fits each situation? Give the reason and the category’s weakness.

(a) “Stop the unit test of computeFee() when all MC/DC test cases have run.” (b) A start-up with no bug records from earlier projects must decide when to stop system testing.

Show solution ↓
Solution

(a) Category 1 (principles and coverage). The stopping point is a planned coverage level. It fits because at unit level the code is visible and coverage can be measured. Weakness: at system or acceptance level there are usually only guidelines, not exact coverage methods, so this category usually does not apply there.

(b) Category 3 (bug-finding trend). Category 2 would need statistics from past projects, which the start-up does not have. Category 3 needs no history: count the bugs found per week and stop at the greatest drop in the slope. Weakness: the project must be monitored closely, and a falling rate could also come from weak tests, so it is best combined with Category 1 evidence where coverage can be measured.

Exercise 5

Specification: a cinema lets a customer in free if the customer is under 3 years old or is a staff member. Otherwise, the customer pays a reduced price if they are a student or aged 65 or over. Otherwise, the customer pays the full price.

Turn the words into simple code, list the causes and effects, write the logic of each effect, build the decision table and give one test case per rule. State explicitly your assumption(s).

Show solution ↓
Solution

Simple code first (the professor’s tip), with the “free” rule first because it wins over everything:

int ticket(int age, boolean staff, boolean student) {
    if (age < 3 || staff)            return 0;   // E1: free
    else if (student || age >= 65)   return 1;   // E2: reduced
    else                             return 2;   // E3: full
}

Causes: 1 = age under 3, 2 = staff, 3 = student, 4 = age 65 or over. Effects: E1 = free, E2 = reduced, E3 = full. Assumption: causes 1 and 4 cannot both be true (an E constraint, since an age cannot be under 3 and 65 or over at once).

Logic (else = NOT of everything before):

  • E1 = 1 || 2
  • E2 = (1 || 2)' && (3 || 4)
  • E3 = (1 || 2)' && (3 || 4)'

Decision table: each OR splits into separate rules, so E1 gives two rules, E2 gives two rules and E3 one.

Condition / effectR1R2R3R4R5
1: age under 310000
2: staffX1000
3: studentXX100
4: age 65 or overXXX10
E1 free11000
E2 reduced00110
E3 full00001

Test cases (age, staff, student) → expected:

RuleInputExpected
R1(2, no, no)free (0)
R2(30, yes, no)free (0)
R3(20, no, yes)reduced (1)
R4(70, no, no)reduced (1)
R5(30, no, no)full (2)

Check against the code: (2, no, no) hits age < 3 → 0; (30, yes, no) hits staff → 0; (20, no, yes) passes the first test and hits student → 1; (70, no, no) hits age >= 65 → 1; (30, no, no) falls through to else → 2 ✓.

Exercise 6

Find all minimum MC/DC test sets for Z=A∨(B∧C)Z = A \lor (B \land C). Show the extended truth table.

Show solution ↓
Solution

n=3n = 3, so 8 rows and a minimum of n+1=4n + 1 = 4 tests. Masking: every row with A = T has Z = T.

RowABCZA variesB variesC varies
1FFFF5
2FFTF64
3FTFF74
4FTTT23
5TFFT1
6TFTT2
7TTFT3
8TTTT

Pairs: A {1,5},{2,6},{3,7}\{1,5\}, \{2,6\}, \{3,7\} (rows 4 and 8 are both T, no pair); B {2,4}\{2,4\} only; C {3,4}\{3,4\} only.

B and C have one pair each, so rows 2, 3, 4 are forced. Now add one row to complete an A pair: row 2 needs 6, row 3 needs 7 (the pair {1,5}\{1,5\} would need two new rows).

Minimum test sets: {2,3,4,6}\{2, 3, 4, 6\} and {2,3,4,7}\{2, 3, 4, 7\}, each with n+1=4n + 1 = 4 rows ✓.

Exercise 7

For Z=(A∧B)∨CZ = (A \land B) \lor C, a tester proposes two test sets (row numbers in the standard order):

(a) {3,5,7,8}\{3, 5, 7, 8\} (b) {1,2,3,5,7}\{1, 2, 3, 5, 7\}

For each, say whether it is an MC/DC test set and whether it is minimum.

Show solution ↓
Solution

Truth table (Z is T when C is T, or when A and B are both T):

RowABCZA variesB variesC varies
1FFFF2
2FFTT1
3FTFF74
4FTTT3
5TFFF76
6TFTT5
7TTFT35
8TTTT

Pairs: A {3,7}\{3,7\}; B {5,7}\{5,7\}; C {1,2},{3,4},{5,6}\{1,2\}, \{3,4\}, \{5,6\}.

Pairs first, size second.

(a) {3,5,7,8}\{3,5,7,8\}: A pair {3,7}\{3,7\} ✓, B pair {5,7}\{5,7\} ✓, C: none of {1,2},{3,4},{5,6}\{1,2\}, \{3,4\}, \{5,6\} is complete (row 8’s partner, row 7, has the same result). Not an MC/DC test set, even though it has exactly n+1=4n + 1 = 4 rows.

(b) {1,2,3,5,7}\{1,2,3,5,7\}: A {3,7}\{3,7\} ✓, B {5,7}\{5,7\} ✓, C {1,2}\{1,2\} ✓. It is an MC/DC test set, but not minimum: it has 5 rows, while {3,4,5,7}\{3,4,5,7\} or {3,5,6,7}\{3,5,6,7\} achieve MC/DC with 4.