Shaun Abram
Technology and Leadership Blog
Blog post summary: Test Shapes by Martin Fowler
In his post, “On the Diverse And Fantastical Shapes of Testing“, Martin Fowler talks about the Test Pyramid and Test Trophy, but concludes that the proportions suggested by each are much less important that writing fast, reliable, expressive tests with clear boundaries.
Pyramid vs Trophy
Fowler’s post start by talking about how the general consensus on tests has moved from the Test Pyramid he documented back in 2012:
To more of a Test Trophy:
(As coined by Kent Dodds)
No definitive definitions of unit and integration tests
Fowler goes on to argue that the discussions around such models are “rendered opaque” by the fact that there are widely varying definitions of the terms unit and integration tests.
Some of the definitions include:
- Unit tests test code in isolation, while integration tests how works with code developed separately).
- “Mockist” or “Solitary” unit tests refers to a style of unit tests where any collaborating object are replaced with a Test Double, such as a mock, (I previously wrote about Test Doubles).
- “Classic” or “Sociable” unit tests refers to a style of unit tests where the tested unit relies on other units to fulfill its behavior.
So, you can see there is much rom for confusion. In particular, the concept of “Sociable” unit tests seems remarkably similar to some definitions of integration tests.
On a side note, in a previous post, I defined as:
“A unit test is a piece of code that executes a specific functionality (‘unit’) in the code, confirms the behavior or result is as expected and determines if code is ‘fit for use’”
Kent Beck’s writing suggests a different angle, suggesting who write the tests is a key component, with unit test being written by developers as part of their day-to-day work, as opposed to a separate testing team.
The most important point
The article finishes with two key points:
- The lack of agreed definitions mean that “when anyone starts talking about various testing categories, dig deeper on what they mean”.
- The definitions themselves, or the proportion of one type of test versus another (as suggested by pyramid and trophy) is perhaps not that important. Instead, the important thing is writing expressive tests that establish clear boundaries, run quickly and reliably, and only fail for useful reasons.
Tags: integrationtesting, kentbeck, martinfowler, testdoubles, testpyramid, testshapes, testtrophy, unittesting