Unit testing patterns for Concurrent code
summary
Practical rules and concrete techniques for deterministic tests: prefer the humble object pattern to extract logic away from threads; replace System.Timers.Timer with a wrapped ITimer or a fake (demonstrated with TypeMock Isolator) to drive ticks deterministically; use a custom TaskScheduler trick or DI so tasks run synchronously in tests; coordinate with ManualResetEventSlim (signal pattern) or a busy-assert loop that polls until timeout. Slides and runnable examples live on the referenced GitHub.
AI-written summary · about
chapters (12)
- 0:00Intro
- 2:40Meanwhile in the unit testing "world"
- 3:24The dark art of concurrent code
- 10:47Concurrency test smells
- 14:19Test smell – using "Sleep" in test
- 17:13Humble object pattern
- 18:45Concurrency as part of program flow
- 20:12"Avoid concurrency" Patterns
- 24:52Using Typemock Isolator to fake Timer
- 33:33Running code in "test mode"
- 34:33Run in single thread patterns
- 41:08Synchronized test patterns
related talks
44mTesting the untestable - patterns and use cases analysis
12mDon’t Be ‘Thread’-ened: Testing Multithreaded Code with Confidence
45mTesting the untestable PART II – patterns, use cases and practices
46mTesting the untestable - patterns and use cases analysis
26mTesting the Tricky Stuff
21mTest Kitchen: A Recipe for Good Tests
01h 19mYou Can't Test This? Hammertime!
57mAdvanced Testing Techniques: Tips from the trenches
