~/talk

Unit testing made easy with MockK

Talkat droidcon APAC 2020 · 2020-12-14..12-15· [testing, kotlin]
slides:none on file

Mocks Kotlin objects, extension and top-level functions, private and static methods, constructors, varargs and enums, and verifies call order and counts; uses MockK DSL (every/verify, coEvery/coVerify for suspend functions) and slots/mutable lists to capture arguments. Demo app tests exercise presenter and coroutine-based use cases and report 100% JaCoCo code coverage for covered lines. Notes reduced boilerplate vs Mockito, relaxed mocks to avoid strict exceptions, and a caveat that MockK caches mocks requiring unmockAll/clear in large test suites.

AI-written summary · about

  1. 0:00Introduction and speaker
  2. 2:17What is MockK
  3. 3:19Getting started with MockK
  4. 4:00Mocking basics with MockK
  5. 5:29Verification with MockK
  6. 7:13Mocking methods with parameters
  7. 8:16MockK annotations
  8. 9:41Spies in MockK
  9. 10:45Relaxed mocking
  10. 11:27Relaxing unit functions
  11. 12:10Mocking Kotlin objects
  12. 12:52Mocking objects comparison
  13. 13:34Unmocking objects
  14. 13:54Mocking enums
  15. 14:17Capturing parameters
  16. 15:40Mocking constructors
  17. 16:24Argument matching
  18. 16:45Chaining calls
  19. 17:06Hierarchical mocking
  20. 18:09Verification counts and order
  21. 19:32Verification confirmation
  22. 21:17Mocking functions returning Unit
  23. 21:37Mocking extension functions
  24. 21:58Mocking top-level functions
  25. 22:20Answers in MockK
  26. 22:42Mocking Java static methods
  27. 23:03Mocking private functions
  28. 24:07Mocking varargs
  29. 24:29Mocking coroutines
  30. 25:12Mocking suspend functions
  31. 26:17Mocking default functions
  32. 26:40Demo walkthrough
  33. 35:43MockK limitations and coverage
  34. 36:48Q&A 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.