ENES

Software testing

Checking that software does what it should, mostly with code that tests other code.

A pyramid with many fast unit tests at the base, fewer integration tests in the middle and a few slow end-to-end tests at the top

Software testing is everything done to find out whether a program works before its users do. Some of it is manual: a person clicks through the app looking for problems. Most of it, in modern teams, is automated tests: small programs that call the real code with known inputs and check the result. A test might say: "total([10, 5]) must return 15". If someone later breaks that, the test fails and tells them.

Tests come in layers. Unit tests check one small piece, like a single function, in milliseconds. Integration tests check that pieces work together, for example the code and a real database. End-to-end tests drive the whole app like a user would, opening a browser and clicking buttons; they are the most realistic but also the slowest and most fragile. The usual advice, called the test pyramid, is many unit tests, fewer integration tests and a handful of end-to-end ones.

The main value is confidence to change things. A good test suite runs automatically on every change in the CI pipeline, catching regressions, old features broken by new code, within minutes. Tests are not proof of correctness, though: they only check the cases someone thought of. As the computer scientist Edsger Dijkstra put it, testing can show the presence of bugs, never their absence.

Keep in mind

Go deeper

Related terms

More in Software