Test levels

Software is tested in layers, from a single function up to the whole product in the hands of real users. Each level catches a different kind of bug.

The four levels

Level What is tested Who Catches
Unit One function, class or component Developers Logic errors, edge cases in code
Integration Two or more parts working together Developers, QA Wrong contracts, data format mismatches, broken APIs
System The complete app, end to end QA Broken flows, platform issues, regressions
Acceptance (UAT) The app against business needs Product owner, client, users Wrong requirements, missing features

Unit testing

The smallest piece of code, tested on its own. Dependencies like the network or database are replaced with fakes, so unit tests are fast and run on every commit.

formatPrice(1999, "USD")  -> "$19.99"
formatPrice(0, "USD")     -> "$0.00"
formatPrice(-500, "USD")  -> "-$5.00"

Integration testing

Checks that parts talk to each other correctly: the app and its API, the API and the database, your service and a payment provider.

Where bugs hideEach part can pass its own tests and still fail together. Many production incidents are integration bugs.

System testing

The full app on real devices and browsers, tested the way users use it. This is where QA spends most of its time.

Acceptance testing (UAT)

User acceptance testing answers one question: is this what we asked for? It is done by the people who own the requirements, often with acceptance criteria written in advance.

Given I have items in my cart
When I apply a valid coupon
Then the discount shows on the order summary
And the total is updated before I pay

The test pyramid

Have many fast unit tests at the bottom, fewer integration tests in the middle and a small set of slow end-to-end tests on top. When most tests sit at the top, the suite gets slow and flaky.

        /\        UI / end-to-end   few, slow
       /  \
      /----\      Integration       some
     /      \
    /--------\    Unit              many, fast