Lesson 4 — Foundations

Levels of Testing

Testing happens at multiple levels of granularity — from individual functions to the entire integrated system — each level catching different kinds of problems.

The Four Levels

Each level of testing operates at a different scope, and a healthy testing strategy uses all four together, since each catches different classes of defects.

  • Unit testing — tests a single function or method in isolation.
  • Integration testing — tests how multiple units or modules work together.
  • System testing — tests the entire, fully integrated application as a whole.
  • Acceptance testing — confirms the system meets business requirements and is ready for release, often involving real users or stakeholders.

The Testing Pyramid

A common guideline suggests having many fast unit tests, a moderate number of integration tests, and relatively few slow, expensive end-to-end/system tests — visualised as a pyramid, with the most tests at the fast, cheap base.

Common Mistakes

  • Relying almost entirely on slow, expensive system-level or UI tests, inverting the testing pyramid and making the test suite slow and fragile.
  • Skipping integration testing entirely, assuming that if each unit works alone, they'll automatically work correctly together.
  • Confusing system testing (testing the whole application) with acceptance testing (confirming it meets business needs, often with stakeholder involvement).
  • Writing unit tests that actually depend on external systems like a real database, blurring the line with integration testing.

Professional Tip

Aim for a healthy "testing pyramid": many fast, focused unit tests forming a solid base, a smaller number of integration tests, and the fewest, most selective tests at the slow, expensive system/UI level.

Your Turn

For a simple online store checkout feature, describe one example test at each of the four levels: unit, integration, system, and acceptance.

Mini Quiz

Which level of testing focuses on a single function or method in isolation?