-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: master
Are you sure you want to change the base?
Conversation
1. LogInForm class 생성자 추가는 테스트를 위함 footer 이메일 인증의 경우, 메인페이지 리다이렉트 URL을 넘기는 방법을 좀 더 찾아 봐야 할 것으로 보임
1. 불필요하게 2개가 들어가 있었으며 이를 하나로 수정.
로그인 성공 외에 모두 통과
There was a problem hiding this 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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
해당 변수가 어느 테스트에서 사용되는지 확인하지 못했어요 .🐢
} | ||
|
||
@Test | ||
@DisplayName("로그인 성공") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
해당 테스트 코드는 통과하지 않는 것 같습니다. 확인 부탁드립니다. 👀
@BeforeEach | ||
void setUp() { | ||
MockitoAnnotations.openMocks(this); | ||
userService = new UserService(userRepository, provider, encoder, emailService); | ||
} |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 테스트 애노테이션
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
No description provided.