StudyControllerTest.java
@Transactional
@SpringBootTest
@AutoConfigureMockMvc
@RequiredArgsConstructor
class StudyControllerTest {
@Autowired protected MockMvc mockMvc;
@Autowired protected StudyService studyService;
@Autowired protected StudyRepository studyRepository;
@Autowired protected AccountRepository accountRepository;
...
}
protected를 붙여주었다. 왜?
-> StudySettingsControllerTest 가 StudyControllerTest를 메서드, 필드들을 상속 받아서 사용하도록 하기 위해 😀
StudySettingsControllerTest.java
@Transactional
@SpringBootTest
@AutoConfigureMockMvc
@RequiredArgsConstructor
class StudySettingsControllerTest extends StudyControllerTest {
...
}
출처 : 인프런 백기선님의 스프링과 JPA 기반 웹 애플리케이션 개발