Slice Test (Not Integration Test)

@WebMvcTest

Flow

HTTP Request
↓
Controller (REAL)
↓
Service (@MockBean)
❌ Repo
❌ DB

So must use @MockBean, else Spring will say bean not found.

Example:

@WebMvcTest(UserController.class)
class UserControllerTest {

    @Autowired
    MockMvc mockMvc;

    @MockBean
    UserService userService;
}

@DataJpaTest

@DataJpaTest
class UserRepositoryTest {

    @Autowired
    UserRepository repo;
}