~/talk

De-mock your tests

Talkat droidcon Berlin 2022 · 2022-07-06..07-08· [testing, kotlin]
links:none on file
slides:none on file

Argues that overusing Mockito/MockK harms code and shows concrete replacements: implement a fake database using an internal list/map instead of method-by-method mocks, convert single-use interfaces into functional single-method providers to stub suspend calls in plain Kotlin, record UI interactions with a view-robot that stores state changes rather than verify calls, and plant a Timber test tree to collect log entries. Recommends mocks only for unmodifiable legacy or final classes; fakes improve readability, reuse, and portability to multiplatform.

AI-written summary · about

  1. 0:00Introduction and story
  2. 1:32Unit testing basics
  3. 3:22Test doubles and mocks
  4. 5:09Mocking database with fakes
  5. 7:41Stubbing use cases
  6. 10:32MVP testing with view robots
  7. 13:42Testing side effects
  8. 14:48Mocking callbacks
  9. 17:42Mocking static methods
  10. 20:12Removing static mocks
  11. 21:57When to use mocks vs fakes
  12. 24:07Mocking anti-patterns
  13. 26:16Summary and conclusion
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.