게시글
질문&답변
CommentServiceTest에서 테스트 오류가 나요.
CommentService 파일과 CommentServiceTest 파일 모두 복붙해서 진행해도 해결이 안되어서, 두개의 파일 모두 삭제하고 다시 복붙해서 넣으니까 해결되었습니다!감사합니다!
- 0
- 4
- 67
질문&답변
CommentServiceTest에서 테스트 오류가 나요.
strictness 설정으로 해결하였습니다.그러나 강사님과 같은 개발환경으로 버전까지 똑같이해서 작성하는데 왜 차이가 나는지 알고싶어요. 추가로, 3번째 테스트 에도 오류가 납니다.@Test @DisplayName("하위 댓글이 삭제되고, 삭제된 부모면, 재귀적으로 모두 삭제한다.") void deleteShouldDeleteAllRecursivelyIfDeleteParent() { // given Long articleId = 1L; Long commentId = 2L; Long parentCommentId = 1L; Comment comment = createComment(articleId, commentId, parentCommentId); given(comment.isRoot()).willReturn(false); Comment parentComment = createComment(articleId, parentCommentId); given(parentComment.isRoot()).willReturn(true); given(parentComment.getDeleted()).willReturn(true); given(commentRepository.findById(commentId)) .willReturn(Optional.of(comment)); given(commentRepository.countBy(articleId, commentId, 2L)).willReturn(1L); given(commentRepository.findById(parentCommentId)) .willReturn(Optional.of(parentComment)); given(commentRepository.countBy(articleId, parentCommentId, 2L)).willReturn(1L); // when commentService.delete(commentId); // then verify(commentRepository).delete(comment); verify(commentRepository).delete(parentComment); }(사진)
- 0
- 4
- 67