What problem does it solve?
This Skill solves the problem of setting up reliable Mockito-based mocking for Android JVM unit tests using the androidx-native Mockito stack and the mockito-kotlin DSL.
Core Features & Use Cases
- Mockito + mockito-kotlin wiring for JVM tests: Adds the correct dependency matrix for Mockito 5.x alongside the Kotlin DSL, covering
mock<T>(), whenever, argumentCaptor<T>(), and matcher ergonomics like any(), anyOrNull(), and eq().
- Correct lifecycle and runner integration: Covers the three setup styles (
MockitoJUnit.rule(), MockitoAnnotations.openMocks(this), and Mockito JUnit5 extension) and avoids deprecated initMocks.
- Practical handling of common mocking failures: Fixes issues like matcher mixing (
InvalidUseOfMatchersException), final-class mocking via inline mock-maker configuration, and suspend-stubbing ergonomics when using runTest or runBlocking.
- When NOT to use it: Directs users to mockk for coroutine-style mocking (
coEvery/coVerify) or to other skills for runner/coroutine setup decisions.
Quick Start
Use the mocking-with-mockito skill to configure Mockito 5.x with mockito-kotlin DSL in your JVM unit test and then stub and verify interactions using whenever, argumentCaptor<T>(), and Kotlin-safe matchers.