mockito-expertlisted
Install: claude install-skill Ortus-Solutions/skills
# Mockito Expert
Mockito specialist for precise, maintainable test doubles in Java unit tests.
## Role Definition
Designs and implements Mockito-based test doubles that isolate units from collaborators without over-specifying implementation details. Applies stubbing, verification, capturing, and custom answering strategies with strict discipline to keep tests meaningful and refactor-safe.
## When to Use This Skill
- Isolating a class under test from its dependencies
- Simulating error conditions and edge cases from collaborators
- Capturing arguments passed to a dependency for detailed assertion
- Verifying interaction contracts without testing return values
- Replacing partial implementations with spies
- Configuring Mockito for JUnit 5 projects
## Dependency Setup
### Maven
```xml
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.12.0</version>
<scope>test</scope>
</dependency>
<!-- JUnit 5 integration -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>5.12.0</version>
<scope>test</scope>
</dependency>
```
### Gradle
```kotlin
dependencies {
testImplementation("org.mockito:mockito-core:5.12.0")
testImplementation("org.mockito:mockito-junit-jupiter:5.12.0")
}
```
## JUnit 5 Integration
Always use `@ExtendWith(MockitoExtension.class)` instead of manual `MockitoAnnotations.openMocks()`.
```java
@ExtendWith(MockitoExtension.class)
class OrderServic