From Test Data Builders to the identity functor by Mark Seemann
The Test Data Builder unit testing design pattern is closely related to the identity functor.
The Test Data Builder design pattern is a valuable technique for managing data for unit testing. It enables you to express test cases in such a way that the important parts of the test case stands out in your code, while the unimportant parts disappear. It perfectly fits Robert C. Martin's definition of an abstraction:
"Abstraction is the elimination of the irrelevant and the amplification of the essential"Not only are Test Data Builders great abstractions, but they're also eminently composable. You can use fine-grained Test Data Builders as building blocks for more complex Test Data Builders. This turns out to be more than a coincidence. In this series of articles, you'll learn how Test Data Builders are closely related to the identity functor. If you don't know what a functor is, then keep reading; you'll learn about functors as well.
- Test Data Builders in C#
- Generalised Test Data Builder
- The Builder functor
- Builder as Identity
- Test data without Builders
- (The Test Data Generator functor)
- How to make your code easier to use in unit tests.
- What a functor is.
- How Test Data Builders generalise.
- Why Test Data Builders are composable.
For readers wondering if this is 'yet another monad tutorial', it's not; it's a functor tutorial.
Next: Test Data Builders in C#.