2일차. Triple 여행자 클럽 마일리지 서비스

2일차 진행

ApiEventController 생성,

Reveiw 관련 Service, Repository, Dto 등을 생성하고 간단한 로직 구현(ADD, MOD, DELETE)하여 생성하는 것을 확인하고자 함.

 

느낀점

기타 설계적으로 필요로 하거나, 성능/ Refactoring 측면에서 어떻게 하면 좋을 지 계속 찾아보고 있음.

Spring boot를 사용해서 이렇게 과제,실 서비스와 유사한 것의 개발을 하는 게 어렵기도 하지만 배우고 무엇보다 하나하나 해결해나가는 재미가 있다.

 

이슈, 문제점

TestCode를 작성해보려고 Refernce 들을 찾고 Controller 테스트를 위해 Mockmvc 이용하고자 하였으나

이상하게도 Autowired 시 계속 Bean을 찾을 수 없다는 Error 가 발생하여 @AutoConfigureMockMvc 도 넣어보고, 했으나 잘안되어 하기 코드로 일단 작성하여 넘어감.

using a Junit Jupiter 의 @Test 어노테이션을 사용하고 있어, Jupiter로 변경하고 @Extendwith로 변경함. 

@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
@ExtendWith(SpringExtension.class)
@WebMvcTest(ApiEventController.class)
public class ApiEventControllerTest {

    @Autowired
    MockMvc mockMvc;

https://stackoverflow.com/questions/63311426/mockmvc-is-not-autowired-it-is-null

 

MockMVC is not autowired, it is null

I am having an issue with injecting MockMvc to my test class. I tried a few options, but none of them works. 1 option: basically the same as here, manually creating MockMvc @Autowire MockMvc - Spring

stackoverflow.com