
Unit tests are faster to write than GUI tests (less development time). Unit tests also run faster than GUI tests.
Unit tests are cheaper than GUI tests (though climbing toward the top of the pyramid gives more confidence that everything works as expected).
Testing should be multi-layered, but the proportions matter: there should be more unit tests than GUI tests by count. Service / system tests sit in the sweet middle.
The concept was first described in Succeeding with Agile: Software Development Using Scrum by Mike Cohn, 2009.
Further reading on the topic (including the “ice cream cone” anti-pattern):
- The Forgotten Layer of the Test Automation Pyramid
- Martin Fowler: TestPyramid
- The Practical Test Pyramid
- Agile Nutshell: The Testing Pyramid
- Google Testing: Just Say No to More End-to-End Tests
- The Evolution of the Testing Pyramid
- Testing Tips & Tricks — WWDC 2018