HTTP Request
↓
Controller (REAL)
↓
Service (@MockBean)
❌ Repo
❌ DB
So must use @MockBean, else Spring will say bean not found.
@WebMvcTest(UserController.class)
class UserControllerTest {
@Autowired
MockMvc mockMvc;
@MockBean
UserService userService;
}
@DataJpaTest
class UserRepositoryTest {
@Autowired
UserRepository repo;
}