Journey to an FP Test Harness
summary
Case study traces converting Play API tests from Future-heavy, mutable traits into a pure-FP harness built with Cats IO and state transformers. Code moves from blocking Play helpers and cake-style self-types to a single TestOp type defined as StateT[IO], uses IndexedStateT to model phase changes, and maintains a cache of clients for multi-user tests. Play result helpers get rewritten, the harness composes and runs deterministically, and the experiment succeeds.
AI-written summary · about
chapters (10)
- 0:00Start
- 0:57Background
- 3:05Functional Tests
- 4:17Test Code Is Code
- 11:06Monads
- 15:18Api Tests
- 15:53Futures and Side-Effects
- 18:05Helper Methods
- 21:57Clean Up the Play Helpers
- 27:04Model Phase Changes in the Test
related talks
38mIntro to FP in Scala: Exploring a Toolbox for Solving Problems - Part 5 of 6
46mTesting in the world of Functional Programming
28mAdopting Cats
01h 03mIntro to FP in Scala: Exploring a Toolbox for Solving Problems - Part 4 of 6
44mMonads for Testers
49mRefactoring toward a more functional style in F#
50mFunctional Programming with Effects
45mOh, All the things you'll traverse
