-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] - BE 테스트 개선 1단계 Test Fixture 운용 방식 통일 (Enum Fixture) (#614)
* test: OauthUserFixture - Enum 기반의 Fixture로 전환 * test: MemberFixture - EnumFixture 컨벤션 통일 개선 * test: MemberFixture 속성을 가지는 Member를 만드는 Request 객체 생성하는 기능 추가 * test: MemberFixture 속성을 기반으로 Request 객체를 만들도록 테스트 코드 수정 * test: OauthUserFixture의 팩토리 메서드 이름 수정 (createXXX -> getXXX) * test: MemberFixture의 팩토리 메서드 이름 수정 (createXXX -> getXXX) * test: 사용되지 않는 Fixture 클래스 제거 개선 * test: Travelogue관련 Enum Fixture 컨벤션 통일 개 * test: TravelogueCountry, TravelogueDay 도메인 테스트 중복 데이터 셋팅 제거 개선 * test: Request 객체 생성 도메인 Fixture 내부로 응집 * test: 도메인 구성 시 연관관계를 직접 주입하도록 테스트 코드 수정 * test: CountryCode 패키지 위치 수정 * test: TraveloguePhotoTest 연관관계 도메인 주입을 셋업 코드로 이동 개선 * test: Fixture를 통한 도메인 생성 시 연관관계를 주입하도록 로직 수정 * test: 사용하지 않는 상수 제거 개선 * test: 반복되는 메서드 모킹 setUp으로 이동 * test: 반복되는 메서드 모킹 setUp으로 이동 * test: 연관 관계를 가지는 Fixture를 주입받아 Request객체를 생성하는 기능 추가 * test: TravelogueRequestBuilder 구현 * test: TravelogueRequestBuilder에서 DayBuilder 체크로직 제거 * test: 실패하는 테스트 수정 * test: RequestBuilder 객체 패키지 이동 fixture -> helper * test: TravelPlan관련 fixture에 연관 도메인 관련 내용 제거 * test: TravelPlaceTodoFixture 구현 * test: Fixture를 통해서 Request 객체 만드는 기능 구현 * test: TravelPLanRequestBuilder 구현 * test: 과거 날짜 여행기 픽스쳐 추가 * test: Builder 클래스 개행 수정 * test: TravelPlanControllerTest에서 Request를 생성 시 RequestBuilder를 이용하도록 개선 * test: 사용하지 않는 테스트 상수 제거 개선 * test: TravelogueCountryTest 줄바꿈 컨벤션 적용 * test: TraveloguePlaceFixture 줄바꿈 컨벤션 적용 및 사용하지 않는 메서드 제거 개선 * test: TravelogueRequestBuilder와 TravelogueDayRequestBuilder 별도 클래스로 분리 * test: TravelPlanRequestBuilder와 PlanDayRequestBuilder 별도 클래스로 분리 * test: MemberFixture 이름 변경 DEFAULT_MEMBER -> TOUROOT_LOCAL_USER
- Loading branch information
Showing
38 changed files
with
1,008 additions
and
433 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
backend/src/test/java/kr/touroot/authentication/fixture/OauthUserFixture.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package kr.touroot.authentication.fixture; | ||
|
||
import kr.touroot.authentication.dto.response.OauthUserInformationResponse; | ||
import kr.touroot.authentication.dto.response.kakao.KakaoAccount; | ||
import kr.touroot.authentication.dto.response.kakao.KakaoProfile; | ||
import lombok.AllArgsConstructor; | ||
|
||
@AllArgsConstructor | ||
public enum OauthUserFixture { | ||
|
||
KAKAO_USER(1L, "test_nickname", "https://test_img_src.com"); | ||
|
||
private final Long socialLoginId; | ||
private final String nickname; | ||
private final String profileImagePath; | ||
|
||
public OauthUserInformationResponse getOauthInformationResponse() { | ||
KakaoProfile kakaoProfile = new KakaoProfile(nickname, profileImagePath); | ||
KakaoAccount kakaoAccount = new KakaoAccount(kakaoProfile); | ||
return new OauthUserInformationResponse(socialLoginId, kakaoAccount); | ||
} | ||
} |
12 changes: 0 additions & 12 deletions
12
backend/src/test/java/kr/touroot/authentication/fixture/OauthUserInformationFixture.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,17 +2,31 @@ | |
|
||
import kr.touroot.member.domain.LoginType; | ||
import kr.touroot.member.domain.Member; | ||
import kr.touroot.member.dto.request.MemberRequest; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@AllArgsConstructor | ||
@Getter | ||
public enum MemberFixture { | ||
|
||
KAKAO_MEMBER(1L, null, null, "https://dev.touroot.kr/temporary/profile.png", "리비", | ||
LoginType.KAKAO), | ||
DEFAULT_MEMBER(null, "[email protected]", "password", "https://dev.touroot.kr/temporary/profile.png", "뚜리", | ||
LoginType.DEFAULT); | ||
KAKAO_MEMBER( | ||
1L, | ||
null, | ||
null, | ||
"https://dev.touroot.kr/temporary/profile.png", | ||
"리비", | ||
LoginType.KAKAO | ||
), | ||
TOUROOT_LOCAL_USER( | ||
null, | ||
"[email protected]", | ||
"password", | ||
"https://dev.touroot.kr/temporary/profile.png", | ||
"뚜리", | ||
LoginType.DEFAULT | ||
), | ||
; | ||
|
||
private final Long socialId; | ||
private final String email; | ||
|
@@ -21,10 +35,34 @@ public enum MemberFixture { | |
private final String nickname; | ||
private final LoginType loginType; | ||
|
||
public Member build() { | ||
public Member getMember() { | ||
if (loginType == LoginType.KAKAO) { | ||
return new Member(socialId, nickname, profileImageUrl, loginType); | ||
} | ||
return new Member(email, password, nickname, profileImageUrl, loginType); | ||
} | ||
|
||
public MemberRequest getCreateRequest() { | ||
return new MemberRequest(email, password, nickname, profileImageUrl); | ||
} | ||
|
||
public MemberRequest getCreateRequestWithEmail(String email) { | ||
return new MemberRequest(email, password, nickname, profileImageUrl); | ||
} | ||
|
||
public MemberRequest getCreateRequestWithPassword(String password) { | ||
return new MemberRequest(email, password, nickname, profileImageUrl); | ||
} | ||
|
||
public MemberRequest getCreateRequestWithNickname(String nickname) { | ||
return new MemberRequest(email, password, nickname, profileImageUrl); | ||
} | ||
|
||
public MemberRequest getCreateRequestWithProfileImageUrl(String profileImageUrl) { | ||
return new MemberRequest(email, password, nickname, profileImageUrl); | ||
} | ||
|
||
public MemberRequest getCreateRequestWithEmailAndNickname(String email, String nickname) { | ||
return new MemberRequest(email, password, nickname, profileImageUrl); | ||
} | ||
} |
34 changes: 0 additions & 34 deletions
34
backend/src/test/java/kr/touroot/member/fixture/MemberRequestFixture.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.