Skip to content

Testing

The Testing Pyramid

The testing pyramid is a concept that helps guide how many tests of each type you should write:

text
        /\
       /  \      ← UI Tests (Few, Slow, High-level)
      /────\
     /      \    ← Integration Tests (Some, Medium speed)
    /────────\
   /          \  ← Unit Tests (Many, Fast, Low-level)
  /────────────\

Recommended distribution:

  • 70% Unit tests - Fast, isolated, test individual functions/methods
  • 20% Integration tests - Test components working together
  • 10% UI tests - Test critical user journeys end-to-end

Why this ratio?

  • Unit tests are fast and catch most bugs early
  • Too many UI tests = slow test suite and high maintenance
  • UI tests focus on critical paths, not every edge case

Comparison of test types

AspectUnit TestsIntegration TestsUI Tests
ScopeSingle function/methodMultiple componentsEntire application
Speed⚡⚡⚡ Very fast⚡⚡ Fast🐌 Slow
Reliability✅ Very stable✅ Stable⚠️ Can be flaky
Maintenance✅ Low🟡 Medium⚠️ High
Debugging✅ Easy🟡 Medium⚠️ Difficult
CoverageDetailedModerateHigh-level
When to useAlways, manyFor integrationsCritical paths only
Exampleadd(2, 3) === 5API + DB testFull checkout flow
Further information

Link: UI Tests

Contact: M_Bergmann AT gmx.at