테스트 코드 작성 중, AuthServiceTest에서 NullPointerException 발생 오류 메시지는 아래와 같다. 즉, application-jwt.properties에 담긴 jwt.secret 값을 @Value로 가져오는데, 테스트 코드에서는 해당 부분을 가져오지 못하여서 NullPointerException이 발생하였다. 의아한 점은 테스트 코드 상에서는 오류가 발생하지만, Postman으로 테스트 한 결과 정상적으로 Access, Refresh Token이 생성되는 것을 확인할 수 있었다. 1. 전체 코드 AuthServiceTest NullPointerException이 발생한 테스트 코드 @SpringBootTest(properties = "spring.config.location=..
@WebMvcTest를 사용하여 junit5 테스트 코드를 작성하는 중, 아래와 같은 오류 발생 소스 코드 @Test @DisplayName("닉네임 검증; 공백이 들어오면 CustomException 을 발생시킨다") public void NicknameIsBlank() throws Exception { mvc.perform(get("/api/auth/check-nickname") .queryParam("nickname", " ")) .andExpect(status().isBadRequest()) .andExpect(jsonPath("$.message", is(ErrorCode.NICKNAME_CONTAINS_BLANK.getMessage()))) .andExpect(jsonPath("$.code", ..
1. Test class, test methods, and lifecycle methods are not required to be public, but they must not be private. IntelliJ에서 test class를 만들면 아래와 같은 양식으로 만들어진다. 하지만 Junit5 부터는 class 명칭 앞에 public 을 생략해도 상관없다. Junit5 Document 2.3에서, 기술적인 문제가 없다면 test class, test methods, and lifecycle methods에 public 을 붙이는 것을 권장하지 않는다고 작성되어 있다. class SessionManagerTest { } 2. JpaRepository에서 테스트 코드를 어느 정도까지 작성해야 하는가?..