TDD + Test Pyramids

TDD = Test > Code (make it work) > Refactor (make it simple) Test Pyramid = lots of small/unit tests, few integration, fewer e2e

What tends to happen when we couple them:

Unit Test > Code > Tests are tightly bound to the implementation, it's hard to refactor, it works, we move on

The trend has shifted in the past few years towards lifting tests up (ex: https://kentcdodds.com/blog/the-testing-trophy-and-testing-classifications (opens in a new tab)) Thanks to libraries like testing-library https://testing-library.com/ (opens in a new tab). Backend devs are now moving in this direction as well https://www.youtube.com/watch?v=QL0HBeIAny0 (opens in a new tab)

Write tests. Not too many. Mostly integration. (opens in a new tab)

Pain points with TDD+Pyramid can be:

Those are mostly Test Pyramid issues, TDD acts like a catalyst that speeds up the process.

When tests are placed high enough to play a users' role, TDD doesn't have these issues.

It's also great at:

CC BY-NC 4.0 2024 © Shu Ding.