-
Notifications
You must be signed in to change notification settings - Fork 41.5k
Closed
Labels
status: supersededAn issue that has been superseded by anotherAn issue that has been superseded by another
Description
@SpringBootTest(classes = ...)
does not seem to pick classes annotated by JSR-330 @Named
if they have a constructor. It works with other spring annotation (@Component
, @Service
, etc). It works if the class does not have a constructor.
I am using 2.2.6.RELEASE version.
E.g.
The following test fails
@Named
public class DummyService {
DummyService() {
}
}
@SpringBootTest(classes = {DummyService.class})
class DummyTest {
@Autowired
DummyService dummyService;
@Test
void dummyServiceExists() {
assertNotNull(dummyService);
}
}
This change to DummyService would make it succeed:
@Named
public class DummyService {
}
Also the following change to DummyService would make it succeed:
@Component
public class DummyService {
DummyService() {
}
}
Or you can change your test strategy and it would succeed:
@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = {DummyService.class})
class DummyTest {
...
}
Metadata
Metadata
Assignees
Labels
status: supersededAn issue that has been superseded by anotherAn issue that has been superseded by another