Mockito
- Use `@Mock` with `@ExtendWith(MockitoExtension.class)` for automatic mock initialization. Stub with `when(mock.method()).thenReturn(value)`. Verify interactions with `verify(mock).method()`.
Mockito
- Use `@Mock` with `@ExtendWith(MockitoExtension.class)` for automatic mock initialization. Stub with `when(mock.method()).thenReturn(value)`. Verify interactions with `verify(mock).method()`.
- Use `@InjectMocks` to auto-inject mocks into the class under test. Use `ArgumentCaptor<T>` to capture and assert on arguments passed to mocks. Use `doReturn().when()` syntax for void methods and spies. Use `verifyNoMoreInteractions(mock)` to ensure no unexpected calls. Never mock value objects or DTOs — only mock collaborators.