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"
- Ask developers which areas have unit tests, so you don't repeat them by hand.
- A bug you find that a unit test could have caught is worth a unit test.
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.
- Does the app handle every field the API sends, including
null? - What happens when the API is slow, returns an error or times out?
- Do dates, currencies and time zones survive the trip between systems?
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.
- Complete flows: sign up, buy, cancel, sign out.
- Different devices, OS versions, browsers and screen sizes.
- Functional and non-functional checks. See Test types.
- Use an environment that is as close to production as you can get.
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
- Alpha testing: done inside the company, before release.
- Beta testing: done by a group of real users, for example TestFlight or Play Console testing tracks.
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