TOPIC 38/5115 MINNOT STARTED

Cyclomatic complexity and basis path testing

Cyclomatic complexity counts the independent routes through code. That number tells a tester how many tests a basis set needs and how tangled the code is.

L1–L4 are part of the Pro pass

L0 Explain simply

Analogy: counting independent routes through a town. A town has roads and junctions. Some routes are just the same roads in a new mix. Others add a road you have not used. The number of independent routes is how many you must walk, so that every other route is a mix of the ones you walked.

Daily List is a to-do list app. Leo, the developer, has a function with three choices. Tom, the tester, wants to know how many tests he needs to walk every independent route through it.

He draws a , a drawing of code as steps joined by arrows that show the order. Then he works out the , a number that counts the independent paths through a piece of code. Each basis path is one of a set of independent paths that form a basis for the graph.

The number is small for simple code and large for tangled code. For Leo's function it is 4, so Tom writes 4 tests, one for each .

The picture has a limit. A town has roads you can see. In code, a path may be impossible to run, since two choices can rule each other out.

(SYNTHETIC / TRAINING ONLY: Daily List and every person named in this lesson are invented.)

PLAIN WORDS · 1 in this section
cyclomatic
a count of the independent paths through code

PICTURE IT

The picture is the one the lesson above opens with. The table below shows how each part of it matches the software.

THE REAL JOB Counting the independent routes through code and writing one test for each, with extra tests for mixes that could hide a fault.

  1. Count the choices
  2. Add one
  3. One test per path
One rule

HOW THE PICTURE MAPS

How each part of the picture matches the software
In the pictureIn the software
Independent routes through a townBasis paths
Roads and junctionsArrows and boxes in the graph
The count of routes to walkCyclomatic complexity

WHERE THIS PICTURE STOPS

  • A town has roads you can see. Code may hold paths that cannot run.
  • A walker may use any road. A basis set must add a new arrow each time.
  • A count of routes does not say a route is safe.

HOOK

Choices plus one.

REMEMBER IT THIS WAY

A rule of thumb: if you see this, think that.

Usually, count the choices in the code and add one: that is the number of basis paths, so the number of tests to start with.

What each part of the trick stands for
In the trickWhat it stands for
ChoicesThe decisions in the code, three in Leo's function
Plus oneCyclomatic complexity, the number of independent paths

Mixes of choices can hide a fault, so a basis path set may need extra tests.

TELL A FRIEND

counts the independent routes through a town: how many you must walk so that every other route is a mix.

OFTEN MIXED UP WITH Branch coverage. The lesson counts the ways out of choices that tests have taken. This lesson counts the independent routes and plans tests for them.

PRACTISE AND KEEP

Sources for this topic — 4 sources
  1. Market practice

    Structured Testing: A Testing Methodology Using the Cyclomatic Complexity Metric (NIST Special Publication 500-235) ↗ — National Institute of Standards and Technology (NIST) · Structured testing, also called basis path testing, yields a basis set of paths equal in number to the cyclomatic complexity, and gives more thorough testing than statement and branch coverage (search excerpt, page not opened)

    Per the search excerpt, by Wallace, Watson and McCabe (1996). Structured testing, also called basis path testing, yields a basis set of paths equal in number to the cyclomatic complexity of the module, and gives more thorough testing than statement and branch coverage. · Checked 2026-10-18

    Found through a web search; the page was not opened (search excerpt, page not opened). Version: 1996. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.

  2. Market practice

    A Complexity Measure (Thomas McCabe, Transactions on Software Engineering of the Institute of Electrical and Electronics Engineers (IEEE), 1976) ↗ — Institute of Electrical and Electronics Engineers (IEEE) · The measure is taken from the control flow graph; for one entry and one exit it equals the number of decisions plus one; McCabe suggested splitting a routine above ten (search excerpt of a course copy, page not opened)

    Per the search excerpt, the paper proposes a graph-based measure taken from the control flow graph. For one entry and one exit it equals the number of decisions plus one. McCabe suggested splitting a routine above ten. The URL is a course copy of the paper. · Checked 2026-10-18

    Found through a web search; the page was not opened (search excerpt, page not opened). Version: IEEE Transactions on Software Engineering, vol. SE-2, no. 4, December 1976. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.

  3. Market practice

    ISTQB Certified Tester Foundation Level Syllabus v4.0.1 ↗ — International Software Testing Qualifications Board · Section 4.3 on white-box techniques covers statement and branch testing, which are based on the structure of the code (confirmed against the syllabus, read in full text from a mirror copy of the publisher PDF, v4.0.1, 15 September 2024)

    The examinable statement of what a foundation-level tester is expected to know: six chapters, 64 learning objectives, each tagged K1 Remember, K2 Understand or K3 Apply, plus the test-design techniques the qualification names and groups as black-box, white-box and experience-based.

    Used here for the test-craft questions a Payment Quality Assurance Analyst and a Production Support Analyst are asked. It is cited for what the syllabus says a tester must be able to do, never as a rule about how payments work. · Checked 2026-11-07

    v4.0.1 is dated 15 September 2024 and is a list of corrections to v4.0 (21 April 2023) that reworded six learning objectives — not a cosmetic reissue. 78 pages.

    Two traps this entry exists to stop. v4.0.2 is the German edition (1 March 2025, 94 pages), so sorting by version number reaches the wrong document. And the widely-repeated per-chapter question allocation "8 / 5 / 4 / 11 / 9 / 3" is wrong: it is 8 / 6 / 4 / 11 / 9 / 2, derived from three official sample-exam answer keys and confirmed against the Exam Structure Tables.

    The single most consequential detail for a question bank: white-box coverage — statement and branch — is K2 "Explain", not K3 "Apply" (FL-4.3.1, FL-4.3.2, FL-4.3.3), and MC/DC, path and condition coverage are declared out of scope in §4.3. A question asking a candidate to compute branch coverage is testing something this syllabus does not.

    Read through a mirror, because the publisher's own domain could not be fetched (a reachability gap, not a statement about the publisher). A 403 there is a policy refusal and says nothing about whether the document exists or is reachable elsewhere.

    Anyone on an unrestricted network should open the canonical URL above and confirm the section and page numbers cited against it. Every claim drawn from this entry is written so that it can be checked against a numbered page.

    Read from two independent PDF-to-markdown conversions mirrored on raw.githubusercontent.com. They are treated as faithful because they were produced by unrelated parties with different tooling, agree on the full 64-item objective set including wording, and reproduce the same internal inconsistency present in the source PDF. Chapter 1 reads "testware that supports" where Appendix B reads "that support". A conversion artefact does not replicate across two toolchains.

    The licence permits attributed non-commercial extracts and use as the basis for articles. Whether a site that sells a pass may rely on that is an owner's decision, not this entry's.

    7 November 2026 review: actual publisher PDF 4.0.1, 15 September 2024, 78 pages, front matter/copyright and relevant numbered operative sections 0.5–0.10 and chapters 1–6 compared with CTFLpractice lessons. Earlier mirror/search descriptions are historical access records. TheK2 white-box objectives require explanation; the source does not justify a categorical ban on small numeric illustrations that support explanation. Later Exam Rules 1.2§4.1.4 usesK2 for keyword definitions, while syllabus§0.5 usesK1; keep dated scopes distinct. No copied questions or figure assets.

  4. Market practice

    More Control Flow Tools (Python tutorial) ↗ — Python Software Foundation · An if statement can have elif and else parts, and a for statement goes over the items of a sequence in order (search excerpt from copies of the tutorial text, page not opened)

    Per the search excerpt (from copies of the tutorial text), an if statement can have zero or more elif parts and an optional else part, and a for statement goes over the items of a sequence in order. The live Python 3 page was not returned. · Checked 2026-10-18

    Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.

Deepest material on this page: L4 — Standards & sources. Where a topic stops short of implementation depth, that is a deliberate coverage decision, not an oversight — see coverage.