Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature testcode user #22

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open

Feature testcode user #22

wants to merge 16 commits into from

Conversation

wsh096
Copy link
Collaborator

@wsh096 wsh096 commented Jun 30, 2023

No description provided.

1. LogInForm class 생성자 추가는 테스트를 위함

footer 이메일 인증의 경우, 메인페이지 리다이렉트 URL을 넘기는 방법을 좀 더 찾아 봐야 할 것으로 보임
1. 불필요하게 2개가 들어가 있었으며 이를 하나로 수정.
로그인 성공 외에 모두 통과
Copy link

@FeelingXD FeelingXD left a comment

Choose a reason for hiding this comment

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

수고하셨습니다. 몇 가지 리뷰 드려요 ! 👍

@Mock
private UserRepository userRepository;
private UserController userController;
private String mainPageUrl;

Choose a reason for hiding this comment

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

해당 변수가 어느 테스트에서 사용되는지 확인하지 못했어요 .🐢

}

@Test
@DisplayName("로그인 성공")

Choose a reason for hiding this comment

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

해당 테스트 코드는 통과하지 않는 것 같습니다. 확인 부탁드립니다. 👀

Comment on lines 49 to 53
@BeforeEach
void setUp() {
MockitoAnnotations.openMocks(this);
userService = new UserService(userRepository, provider, encoder, emailService);
}

Choose a reason for hiding this comment

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

해당부분은 Mock 지정을 위해 추가해주시는거같아요.
위의경우에는 @ExtendWith(MockitoExtension.class) 어노테이션을 통해서 이클래스를실행할시 mockitoExtension을 사용할수있어요 :)
추가적으로 userService 부분은 @InjectMock 어노테이션을통해 가짜객체 를 지정해줄수있을것같아요 .

아래 포스트를 공유해드려요 :)
https://doyoung.tistory.com/12 - junit5 다루기
https://lemontia.tistory.com/951 - @injectmock 과 목객체 다루기

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

@SpringBootTest

Choose a reason for hiding this comment

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

해당 테스트 코드에서 Mock을 이용한 단위테스트를 하는것으로 확인했어요 하지만 통합테스트를 위한 @SpringBootTest어노테이션을 사용한 다른 이유가있을까요 ?🤔

@SpringBootTest는 전체적인 스프링환경 ( 컨텍스트, 환경변수주입 등.) 을 로드하기에 테스트 코드가 무거워질수있어요

아래포스트를 공유해드려요
-https://catsbi.oopy.io/e2fa9884-eb59-4f79-8732-6e3e14e456fd -Spring Boot 테스트 애노테이션

wsh096 added 11 commits July 2, 2023 15:21
1. 필드 변수를 매개변수로 바꿔서 넣어준다.

Controller의 변수
 @value("${mainpage.url}")
    private String MAINPAGE;
아래와 같이 수정해야 합니다.

@value("${mainpage.url}") String MAINPAGE

이렇게 하지 않으면 필드변수

 userController.emailAuth(request, response, mainPage);
 해당 형태의 메서드를 사용할 때, MAINPAGE는 해당 클래스를 선언하며
 null이 되기 떄문
1. 회원가입 검증, 로그인 검증

2. encoder 사용을 위한 설정 추가.
1. 리스트

2. 예약하기/삭제하기
테스트를 위해 @AllArgsConstructor //for test
원본 코드에 일부 추가
# Conflicts:
#	src/main/java/com/zerobase/yogizogi/accommodation/domain/model/RoomDetailForm.java
#	src/main/java/com/zerobase/yogizogi/user/domain/model/LogInForm.java
#	src/main/resources/application-position.properties
#	src/main/resources/application.properties
#	src/main/resources/templates/login.html
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