thinQmaster Virtual testing partner Adaptive practice exams that find your weak spots and drill them. Every answer explained. From $69
Enroll

thinQmaster

Find your exam

Five questions free, before you decide.

Step 1 · choose a vendor

In one of our camps? Your practice exams come with the tuition — they are on your study page already.

DevOps & Automation · Foundational

Unit Test

An automated test that verifies a small, isolated piece of code, such as a function or class, independent of external dependencies.

Definition

Unit tests are fast and numerous, forming the base of the test pyramid. Dependencies are replaced with mocks or stubs. Frameworks include pytest, unittest, JUnit, and xUnit.

Example

A pytest test asserts parse_vlan('10-20') returns a list of 11 VLAN IDs.

Exam tip

Unit tests run earliest in CI; tests that hit real databases are integration tests.

Related terms