Glossary

Unit Testing

A unit test is an automated test that verifies the smallest isolated unit of code (a function or method) in isolation from external dependencies. Runs fast and pinpoints the problem precisely.

Properties of a good unit test (FIRST)

AAA pattern

// Arrange
$calc = new Calculator();
// Act
$result = $calc->add(2, 3);
// Assert
assertEquals(5, $result);

Mocks and stubs

To isolate from DB, API, filesystem: mock (a fake with call verification) and stub (returns preset data, no verification). Popular libraries: PHPUnit, Jest, pytest.