The Test Pyramid Structure
A reliable test suite balances three layers:
1. Unit Tests (Base): Test small functions in isolation. They are fast to run and mock out all external resources.
2. Integration Tests (Middle): Verify that modules work together (e.g. queries against a test database).
3. End-to-End Tests (Apex): Launch the full application and browser to verify user flows, which are thorough but slower and more fragile.
Why Unit Tests Form the Base
Because unit tests run in milliseconds, developers can run hundreds of them on every code change, giving immediate feedback. A healthy test suite has thousands of unit tests and only a few dozen end-to-end tests.
