[HOTFIX-134] 이메일 발송 E2E 테스트 작성#45
Conversation
| password: lossleaderBack12! | ||
| # 데이터베이스 url | ||
| url: jdbc:mysql://218.55.129.211:10000/lossleader | ||
| url: jdbc:mysql://127.0.0.1:3306/lossleader |
| @@ -1,165 +0,0 @@ | |||
| //package lossleaderproject.back.user.service; | |||
There was a problem hiding this comment.
이건 기존에 존재하던 테스트같은데 왜 삭제하셨을까용?
There was a problem hiding this comment.
e2e 테스트가 아니여서 e2e 테스트부터 차근차근 할려는 생각으로 기존에 있던 테스트들을 삭제하였습니다.
| .exchange().expectBody(String.class).isEqualTo("메일 발송성공"); | ||
| } | ||
|
|
||
| } No newline at end of file |
There was a problem hiding this comment.
이거 intellij 에서 eof 설정이 안되어있으신 것 같아요!
이 글 참조하셔서 설정 권장드립니다. :)
| @Test | ||
| @DisplayName("메일 발송") | ||
| public void 메일발송() throws Exception { | ||
| webTestClient.post().uri("/lossleader-user/email").contentType(MediaType.APPLICATION_JSON_UTF8) | ||
| .syncBody(new SendEmail("[email protected]")) | ||
| .exchange().expectBody(String.class).isEqualTo("메일 발송성공"); | ||
| } |
There was a problem hiding this comment.
E2E 테스트도 service 테스트처럼
아래와 같은 방법으로 given when then 구성으로 작성해주세요!
@Test
@DisplayName("가입되어 있는 유저의 이메일 주소를 받았을 때 메일 발송을 성공한다.")
public void 메일발송() throws Exception {
// given
String targetEmail = "[email protected]";
// when
ResponseEntity result = webTestClient.post()
.uri("/lossleader-user/email")
.bodyValue(new SendEmail("[email protected]"))
.retrieve()
.bodyToMono(ResponseEntity.class);
// then
Assertions.assertThat(result.getStatusCode()).isEqualTo(HttpStatus.OK); // 예시
Assertions.assertThat(result.getBody()).isEqualTo("메일 발송성공");
}위처럼 작성할 수 있는건 이 포스팅 참고해서 작성 해주세요! 그리고 이 엔드포인트에 테스트 케이스가 조금 부족한 것 같아요!
제가 생각했을 때는 아래와 같은 케이스들이 존재할 것 같습니다.
아래 번호마다 DisplayName이라고 생각해주시면 좋을 것 같아요.
- 가입되어 있는 유저의 이메일 주소를 받았을 때 메일 발송을 성공한다.
- 미가입 유저의 이메일 주소를 받았을 때 ~~를 응답한다.
- 이메일 주소가 유효하지 않으면 ~~를 응답한다.
혹시 더 있으시면 작성해주시면 좋을 것 같아요!
| @DisplayName("메일 발송") | ||
| public void 메일발송() throws Exception { | ||
| webTestClient.post().uri("/lossleader-user/email").contentType(MediaType.APPLICATION_JSON_UTF8) | ||
| .syncBody(new SendEmail("[email protected]")) |
There was a problem hiding this comment.
SendEmail 이라는 class는 어떤 역할을 하는 class인지 잘 확인이 어려운 것 같아요!
해당 class는 서버에서 request body로 받는 값이니까 SendEmailRequest 로 바꾸면 좋을 것 같은데 어떻게 생각하세용?
|
그리고 현재 이 PR 그리고 commit message는 Prefix를 붙여주세요. 실제 메세지 내용은 작업에 대한 간략한 설명이 있으면 좋습니다. |
e170ce2 to
88cd73a
Compare
E2E Test - 이메일 발송