-
Notifications
You must be signed in to change notification settings - Fork 41.6k
Closed
Description
The following code taken from the doc doesn't work as expected:
@RunWith(SpringRunner.class)
@WebMvcTest(TestController.class)
public class TestControllerTest {
@MockBean
private TestValidator testValidator;
@Autowired
private TestRestTemplate restTemplate;
@Test
public void test() throws Exception {
// no-opts
});
}... where's the mocked bean is:
@Component
public class TestValidator implements Validator {
@Autowired
private TestRepository testRepository;
...
}during test startup it fails:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'testController': Unsatisfied dependency expressed through field 'testValidator': Error creating bean with name 'com.example.TestValidator#0': Unsatisfied dependency expressed through field 'categoryRepository': No qualifying bean of type [com.example.TestRepository] found for dependency [com.example.TestRepository]: expected at least 1 bean which qualifies as autowire candidate for this dependency.
Java: 1.8.0_65
Spring Boot: 1.4.0.RELEASE & 1.4.1-BUILD-SNAPSHOT
Maven: 3.3.3
Metadata
Metadata
Assignees
Labels
type: bugA general bugA general bug