Software is tested at different scales: one function, a few components working together, the whole system, and complete user journeys from the browser to the database and back. Each level finds different kinds of defects, runs at a different speed, and costs a different amount to maintain. This lesson explains the testing levels, the difference between functional and non-functional testing, where smoke and regression testing fit, and how to choose a balanced mix instead of testing everything at one level.
Before you start
Read What Is Software Testing? Understanding QA, QC, and Software Quality first. It helps to know roughly how a web application is built: a front end, an API, and a database.
The four testing levels
Unit testing
A unit test checks the smallest testable piece of code, usually a function or a class, in isolation from the rest of the system. It runs in milliseconds and needs no network, database, or browser.
it("adds up price times quantity", () => {
expect(cartTotal([{ name: "Miso", priceCents: 450, quantity: 2 }])).toBe(900);
});Unit tests are precise: when one fails, it points to a specific function. They're ideal for business rules, calculations, parsing, and edge cases. What they can't tell you is whether the pieces fit together.
Integration testing
An integration test checks that components work together correctly: your code with a real database, two services talking over HTTP, or a module and the library it depends on. Integration tests catch the defects that live between components: a wrong column name, a missing database constraint, a transaction that doesn't roll back, an API that returns a different shape than the client expects.
They're slower than unit tests and need more setup (a test database, a running service), but they test things unit tests can't. Lesson 7 covers them in depth.
System testing
A system test evaluates the complete, integrated system against its requirements, in an environment as close to production as practical. It covers both what the system does and how well it does it: performance, security, and usability are often tested at this level.
End-to-end (E2E) testing
An end-to-end test follows a real user journey through the whole stack: open the browser, sign in, add an item to the cart, check out, and confirm the order appears. It's the closest automated test to what users actually do. E2E tests catch problems no lower level sees, like a button hidden behind a cookie banner or a front end calling the wrong API version. They're also the slowest, the most expensive to maintain, and the most prone to flakiness, so you write fewer of them. Lesson 8 covers E2E testing with Playwright.
Acceptance testing
Separately from these technical levels, acceptance testing asks whether the software meets the needs of its users or customers and is ready to be accepted. It may be done by users, product owners, or automated tests written in the language of the business. It answers the question from lesson 1: did we build the right thing?
Functional and non-functional testing
At every level, you can test two kinds of things:
- Functional testing checks *what* the system does: does the discount apply, does sign-in reject a wrong password, does the export contain every row?
- Non-functional testing checks *how well* it does it: performance (lesson 11), reliability, security (lesson 14), accessibility and compatibility (lesson 12), and maintainability.
Teams often test functions thoroughly and leave non-functional qualities until users complain. Plan both from the start.
Smoke, sanity, and regression testing
These names describe the *purpose* of a test run, not a level:
- A smoke test is a small, fast set of checks that the most important things work at all: the application starts, the home page loads, sign-in works. Run it after every deployment. If it fails, nothing else is worth testing.
- A sanity check is a quick, narrow check that a specific fix or change works, before deeper testing.
- Regression testing re-runs existing tests after a change to make sure nothing that used to work is broken. Automated test suites are mostly regression tests: every bug you fix should leave a test behind so it can't return (lesson 5).
A smoke test after deployment can be as small as this:
#!/bin/sh
set -eu
base="${1:?usage: smoke.sh https://your-app.test}"
curl -fsS "$base/health" > /dev/null
curl -fsS "$base/" | grep -q "<title>"
echo "smoke test passed"Static testing
Not all testing runs code. Static testing examines artifacts without executing them:
- Reviews of requirements, designs, and code (Pull Requests, Merge Requests, Code Reviews, and Team Collaboration in our Git series covers code review).
- Static analysis tools: type checkers like TypeScript's compiler, linters, and security scanners.
Static testing finds some defects earlier and more cheaply than any test run. A type error caught by tsc never needs a unit test.
Choosing the mix: pyramids and trophies
You can't test everything at every level, so how much of each should you write? Two popular models give guidance:
- The test pyramid recommends many fast unit tests at the bottom, fewer integration tests in the middle, and a small number of E2E tests at the top. The reasoning: lower-level tests are faster, cheaper, and more precise.
- The testing trophy, popular for front-end applications, puts static analysis at the base and emphasizes integration tests, arguing they give the most confidence for the effort because they test the way pieces really connect.
Both agree on the important parts: get feedback fast, put most detailed checks at lower levels, keep a small number of high-value E2E tests for critical journeys, and avoid an "ice cream cone" where most testing is slow, manual, or end-to-end.
A practical rule: test each behavior at the lowest level that can actually catch its defects. A rounding rule belongs in a unit test. A database constraint needs an integration test. "A customer can complete checkout" deserves one E2E test.
Testing levels in different technologies
The levels are the same in every stack; the tools differ:
- TypeScript and JavaScript: Vitest or Jest for unit and integration tests, Playwright for E2E.
- Rust: unit tests in the same file as the code in a
#[cfg(test)]module, integration tests in thetests/directory, both run bycargo test. - PHP: PHPUnit or Pest, with Laravel adding helpers for HTTP and database tests.
- Desktop apps such as those built with Tauri: unit tests in Rust and TypeScript, plus E2E tests driving the app window through WebDriver.
Common mistakes and troubleshooting
- Testing everything through the UI. E2E tests for every edge case are slow and fragile. Push detailed checks down to unit tests.
- Only unit tests. Every unit passes and the system still fails at the seams. Add integration tests for the connections that matter.
- Mocking everything in "integration" tests. If the database is mocked, the test can't catch database problems.
- No smoke test after deploys. A broken release can sit unnoticed until users report it.
- Ignoring non-functional qualities. Plan performance, accessibility, and security testing alongside functional testing.
- Slow suites nobody runs. If tests take too long, developers stop running them. Keep the fast feedback loop fast.
Practical exercise: map tests to levels
For a feature such as "a customer books a cooking class":
- List ten behaviors to test, such as "rejects a booking when the class is full," "sends a confirmation email," and "the booking page works on a phone."
- Assign each to the lowest level that can catch its defects: unit, integration, system, or E2E.
- Mark which are functional and which are non-functional.
- Choose the three checks that would make a good smoke test after deployment.
- Draw your result as a pyramid or a trophy. Is anything at too high a level?
Key takeaways
- Unit tests check small pieces in isolation; integration tests check pieces together; system tests check the whole; E2E tests follow real user journeys.
- Acceptance testing asks whether the software meets users' needs.
- Test functional and non-functional qualities at every level.
- Smoke tests check the basics after deploys; regression tests protect what already works.
- Test each behavior at the lowest level that can catch its defects, with a few E2E tests for critical journeys.
References
- ISTQB Certified Tester Foundation Level syllabus (opens in a new tab)
- Martin Fowler: The Practical Test Pyramid (opens in a new tab)
- Kent C. Dodds: The Testing Trophy and Testing Classifications (opens in a new tab)
- The Rust Book: Test Organization (opens in a new tab)
- Vitest documentation (opens in a new tab)
- Playwright documentation (opens in a new tab)
What's next
Knowing *where* to test is half the story; the other half is *what* to test. How to Write Effective Test Cases: Test Design Techniques Explained shows how to choose inputs that find defects.

