Testing in the world of Functional Programming
summary
Advocates property-based testing with concrete fixes: uses ScalaCheck plus newtypes and the scala-newtype macro so arbitraries generate valid UUIDs/dates instead of random strings and avoid boxing, and uses refined types for positive ints and URLs so generators match function inputs. Models impure interactions via Tagless Final algebras and test interpreters: Const captures call order, State monad simulates external state, and a discountAll example verifies a 20% fixed-discount property by running the state interpreter and comparing folded totals.
AI-written summary · about
chapters (19)
- 0:00Intro
- 0:28Testing in the world of FP
- 2:31Property-based testing is awesome
- 4:18Property-based testing - Pains
- 6:34Newtype it!
- 8:57scala-newtype
- 13:57Refined-Scalacheck
- 19:13Other great libraries
- 23:54Testing what we don't control
- 26:19How do we use mocking to test 10?
- 27:55Tagless Final - How to
- 29:03An example
- 29:34Using Tagless Final
- 31:20A possible Test interpreter
- 33:34Running the program
- 34:45External world testing continued
- 36:52A complex example
- 44:41Testing external effects-recap
- 45:34Conclusions
related talks
44mMonads for Testers
01h 00mA New Approach to Testing with ScalaCheck / Property Based Testing
31mProperty-based testing - let your testing library work for you
33mAnalyzing Functional Programs
32mGenerative Testing: Properties, State and Beyond
36mTesting for Lawful Good Adventures
45mTDD, as in Type-Directed Development
44mTypes and Property Tests for Software Resiliency
