I have a problem when I want to test controllers using @WebMvcTest - on application load I get:
...
Field customUserDetailsService in com.test.config.SecurityConfig required a bean of type 'com.test.security.CustomUserDetailsService' that could not be found.
The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)
Action:
Consider defining a bean of type 'com.test.security.CustomUserDetailsService' in your configuration.
...
Do you have any idea what is problem? Is it good solution to exclude security?
There are classes:
@RestController
@AllArgsConstructor
public class EmployeeController {
private final EmployeeService employeeService;
@GetMapping
public List<EmployeeDTO> getEmployees() {
return employeeService.getAllEmployees();
}
}
@WebMvcTest(controllers = EmployeeController.class)
class EmployeeControllerTest {
@Autowired
private MockMvc mockMvc;
@InjectMocks
private EmployeeController employeeController;
@Test
void getEmployees_Success() throws Exception {
// mockMvc.perform(get("/employee/all")).andExpect(status().isOk());
}
Aucun commentaire:
Enregistrer un commentaire