Unit tests sit at the very bottom of the testing pyramid: small, fast checks that developers run dozens of times a day. Each test exercises one small piece of code in isolation from the rest of the system, so a failure points straight at the latest change.
The ISTQB test level
The ISTQB glossary calls this level component testing: “a test level that focuses on individual hardware or software components” (the glossary lists module testing and unit testing as synonyms). The CTFL v4.0.1 syllabus adds that component testing, also known as unit testing, checks components in isolation, usually with test harnesses or unit test frameworks, and is normally done by the developers themselves in their own environment. The modern meaning, small tests written by the developer, was established by extreme programming practices and the xUnit family of frameworks.
| ISTQB level | What it checks |
|---|---|
| Component (unit) | individual components in isolation |
| Integration | interactions between components or systems |
| System | the whole system: whether it meets the specified requirements |
What counts as a unit
There is no single answer: in object-oriented code the unit is most often a class, in functional code a function. Martin Fowler advises treating as a unit whatever the team finds convenient; sometimes it is a group of closely related classes, and that is fine. A more important choice is what to do with the neighbours of the code under test. In “sociable” tests the neighbours stay real; in “solitary” tests they are replaced with test doubles. The terms were proposed by Jay Fields. Doubles take the database, the network and random delays out of the test, so it stays fast and predictable.
What a unit test looks like
def slugify(title: str) -> str: return title.strip().lower().replace(" ", "-") def test_slugify(): assert slugify("Unit Test") == "unit-test" assert slugify(" PyCon ") == "pycon"Test frameworks (JUnit for Java, unittest in the Python standard library, which is modelled on JUnit, pytest, and Jest for JavaScript) find the tests, run them and report which check failed. Speed is essential here: Fowler names small size, being written by the developer themselves and running noticeably faster than other kinds of tests as common traits of unit tests, and by Kent Beck’s rule a commit suite should finish within ten minutes. Such suites run in CI on every change, which makes unit tests the first automated line of defence against regressions.
Sources
the term is written from these pages- ISTQB Glossary — component testingglossary.istqb.org/en_US/term/component-testing(opens in a new tab)
- ISTQB — программа CTFL v4.0.1istqb.org/wp-content/uploads/2024/11/ISTQB_CTFL_Syllabus_v4.0.1.pdf(opens in a new tab)
- Martin Fowler — UnitTest (bliki)martinfowler.com/bliki/UnitTest.html(opens in a new tab)
Verified 18 Nov