Video in progress

Junior 🧪 Testing

What does the idea of the test pyramid mean?

The idea is that most of your tests should be fast, cheap unit tests, with fewer integration tests in the middle and very few end-to-end tests at the top. The higher you go, the slower, more expensive and more brittle the tests get.

📖 Answer

Picture this:

        /  E2E  \          a few: browser, whole system
       / integr. \         tens to hundreds: Spring + DB
      /   unit    \        hundreds to thousands: plain classes

Why this shape: an E2E test brings up the whole stack just to check one button click, takes a minute, and can fail from a small network delay. A unit test passes in a millisecond.

If the pyramid is upside down (people call it an "ice cream cone"), meaning most checking is done by hand or through the UI, CI takes half an hour and the team stops trusting the tests.

But this isn't a strict law. In a CRUD service with little logic that mostly reads and writes the database, integration tests give more value. That's why some people propose a "test trophy" shape. Mentioning this nuance in an interview makes a good impression.