Skip to content

test : user/file/content/subscribe/submission/activity domain 테스트 코드 작성#67

Open
gurwls0122 wants to merge 14 commits intomainfrom
test/testcase-except-form-related
Open

test : user/file/content/subscribe/submission/activity domain 테스트 코드 작성#67
gurwls0122 wants to merge 14 commits intomainfrom
test/testcase-except-form-related

Conversation

@gurwls0122
Copy link
Collaborator

PR Desciption

  • user/file/content/subscribe/submission/activity domain의 테스트 코드 작성 및 리팩토링

PR Log

발생했던 문제 혹은 어려웠던 점

영속성 컨텍스트 유지 및 최신화가 어려웠습니다.

새롭게 배우거나 느낀 점

테스트 코드 짜는 방법. 어떤 코드가 나쁜 테스트 코드인가에 대해서 배웠습니다.

고민 사항

  • Submission을 저장할 때 해당 submission의 1대 n매핑 관계에있는 객관식 답변, 주관식 답변이 영속성 컨텍스트에 잘 올라가지 않습니다. 코드 확인 부탁드립니다!
  • 아직 안된 부분(result, eventpublisher, formrespositoryImpl)들에서의 테스트 방법과 업무 분담을 자세히 하고 싶습니다!

Copy link
Collaborator

@minnim1010 minnim1010 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다!!! 테스트 코드 공부하시면서 작성하시느라 힘드셨을 것 같네요. 추가해야 할 케이스는 딱히 없는 것 같습니다. 말씀하신대로 eventPublisher, FormRepositoryImpl, Result 테스트는 다음 회의 안건에 추가하겠습니다. 피드백 확인 부탁드려용!!!

@@ -36,6 +32,6 @@ public class FileController {
@GetMapping("/upload/{fileName}")
@ResponseStatus(HttpStatus.OK)
FileResponseDto createPresignedUrl(@PathVariable String fileName, @AuthenticationPrincipal LoginUserDto loginUser) {
Copy link
Collaborator

@minnim1010 minnim1010 May 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

사용하지 않는 파라미터는 삭제 부탁드립니다!


if (user.getNickname().equals(nickname) || userRepository.existsByNickname(nickname)) {
private void verifyNickname(String nickname) {
userValidateService.validUserNickname(nickname);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

내부에서 닉네임 길이 유효성 검사만 하고 있으니 validUserNicknameLength()로 구체화하면 어떨까요? 메서드명만 봤을 때 verifyNickname()과 무엇이 다른지 구분이 어렵습니다.

}

@Test
void 사이트에_처음_방문하지_않은_사용자는_회원가입_시_예외가_발생한다() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

사이트에 처음 방문하지 않은 사용자 -> 이미 회원가입한 사용자가 더 자세한 설명이라고 생각됩니다!

}

@Nested
class 사용자_인증 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getUserById() 테스트를 작성한 것 같은데 사용자 정보 조회가 아닌지요? 인증이라고 작성하신 이유가 궁금합니다!

}

@Test
void 입력받은_사용자_ID와_세션내_ID가_다를시_예외가_발생한다() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

탈퇴하려는 사용자 id와 로그인한 사용자 id가 다를 시는 어떨까요? 구현보다는 비즈니스적인 용어를 사용하는 것이 좋다고 생각되어서요!

}

@Nested
class 설문_참여 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

예외 발생할 경우가 많네요.. 고생하셨습니다 bbbb

}

public SubmissionResponseDto getSubmission(long formId, LoginUserDto loginUser) {
public SubmissionResponseDto getTempSubmission(long formId, LoginUserDto loginUser) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

null을 반환할 수 있다면 Optional로 감싸면 어떨까요? nullable한 값을 반환할 수 있다는 걸 명시할 수 있으니 좋을 것 같습니다.

@Nested
class 임시_참여_응답_수정 {
@Test
void 사용자는_임시_응답_설문에_대한_응답을_작성할_수_있다() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

사용자는_임시_응답을_수정할_수_있다...가 맞겠죠?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants