-
Notifications
You must be signed in to change notification settings - Fork 0
[fix] 포스트 제목 최대 길이 변경에 따른 유효성 검증 테스트 수정 #100
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -46,10 +46,10 @@ void setUp() { | |
| } | ||
|
|
||
| @Test | ||
| @DisplayName("제목이 15자를 초과하면 검증에 실패한다") | ||
| @DisplayName("제목이 40자를 초과하면 검증에 실패한다") | ||
| void title_Size_초과_실패() { | ||
| // given | ||
| String longTitle = "a".repeat(16); | ||
| String longTitle = "a".repeat(41); | ||
|
|
||
| PostCreateDto.CreateFree dto = new PostCreateDto.CreateFree( | ||
| longTitle, | ||
|
|
@@ -65,7 +65,7 @@ void setUp() { | |
|
|
||
| // then | ||
| assertThat(violations).hasSize(1); | ||
| assertThat(violations.iterator().next().getMessage()).isEqualTo("제목은 15자를 초과할 수 없습니다"); | ||
| assertThat(violations.iterator().next().getMessage()).isEqualTo("제목은 40자를 초과할 수 없습니다"); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| } | ||
|
|
||
| @Test | ||
|
|
@@ -157,10 +157,10 @@ void setUp() { | |
| class PostUpdateDtoValidationTest { | ||
|
|
||
| @Test | ||
| @DisplayName("제목이 15자를 초과하면 검증에 실패한다") | ||
| @DisplayName("제목이 40자를 초과하면 검증에 실패한다") | ||
| void title_Size_초과_실패() { | ||
| // given | ||
| String longTitle = "a".repeat(16); | ||
| String longTitle = "a".repeat(41); | ||
|
|
||
| PostUpdateDto.UpdateFree dto = new PostUpdateDto.UpdateFree( | ||
| longTitle, | ||
|
|
@@ -176,7 +176,7 @@ class PostUpdateDtoValidationTest { | |
|
|
||
| // then | ||
| assertThat(violations).hasSize(1); | ||
| assertThat(violations.iterator().next().getMessage()).isEqualTo("제목은 15자를 초과할 수 없습니다"); | ||
| assertThat(violations.iterator().next().getMessage()).isEqualTo("제목은 40자를 초과할 수 없습니다"); | ||
| } | ||
|
|
||
| @Test | ||
|
|
@@ -242,10 +242,10 @@ class PostUpdateDtoValidationTest { | |
| } | ||
|
|
||
| @Test | ||
| @DisplayName("제목이 15자 정확히 입력되면 검증에 성공한다") | ||
| void title_15자_정확히_성공() { | ||
| @DisplayName("제목이 40자 정확히 입력되면 검증에 성공한다") | ||
| void title_40자_정확히_성공() { | ||
| // given | ||
| String exactTitle = "a".repeat(15); // 정확히 15자 | ||
| String exactTitle = "a".repeat(40); // 정확히 40자 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| PostUpdateDto.UpdateFree dto = new PostUpdateDto.UpdateFree( | ||
| exactTitle, | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
이
41과 같은 매직 넘버는 코드의 가독성과 유지보수성을 저해할 수 있습니다. 클래스 수준에private static final int TITLE_MAX_LENGTH = 40;와 같은 상수를 선언하고, 여기서는TITLE_MAX_LENGTH + 1을 사용하는 것이 좋습니다. 이렇게 하면 제목 최대 길이가 변경될 때 상수의 값만 수정하면 되므로 유지보수가 용이해집니다. 이 파일의PostUpdateDtoValidationTest내의 유사한 테스트(163행)에도 동일하게 적용하는 것을 고려해주세요.