DevPrep

All topics › Software testing

The test pyramid in an iOS project: how many tests of each kind?

Junior PRO

The gist

The test pyramid (Mike Cohn) is a distribution rule: many fast unit tests at the base, fewer integration tests in the middle and very few UI/E2E tests at the top. The higher the level, the more expensive the test: it takes longer to write, runs slower, fails more often without a real bug and points to the cause less precisely. So every check is pushed down to the lowest level where it can still be made.

Ratios like 70/20/10 are a guideline, not a law. The main rule is different: if a behaviour can be verified with a unit test, do not verify it through the UI.

The rest of this answer, with code and interview follow-ups, is in the DevPrep app.

Read the full answer in DevPrep

Practice this before your interview

DevPrep turns these answers into one-minute challenges: what does this code print, find the bug, mock interviews. One challenge a day.

Get DevPrep on the App Store