There are several ways to create mocks in Mockito:
List<String> mockList = mock(List.class);
@Mock
private List<String> mockList;
@MockBean
private UserService userService;
@BeforeEach
void setUp() {
MockitoAnnotations.openMocks(this);
}
The annotation approach is preferred as it makes tests cleaner and more readable.