-
Notifications
You must be signed in to change notification settings - Fork 185
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
3단계 - 테스트를 통한 코드 보호 #391
Open
bperhaps
wants to merge
21
commits into
next-step:bperhaps
Choose a base branch
from
bperhaps:step3
base: bperhaps
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
3단계 - 테스트를 통한 코드 보호 #391
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
24ee5a2
feat(kitchenpos): readme 작성.
bperhaps 9a843ce
refactor(kitchenpos): order line item -> 주문메뉴정보로 변경.
bperhaps ae8d002
refactor(kitchenpos): 주문의 상태 변화 표현.
bperhaps 06cf928
test(kitchenpos): testGlue 뼈대 생성.
bperhaps 23a9612
test(kitchenpos): testGlue context 등록 및 실행 구현.
bperhaps 1392135
test(kitchenpos): testGlue runner 구현.
bperhaps d15f3e9
test(kitchenpos): testGlue 패키지 변경.
bperhaps ee3c941
test(kitchenpos): testGlue support 생성.
bperhaps ce35cba
test(kitchenpos): testGlue 파라메터 추가.
bperhaps b74de49
test(kitchenpos): product 비즈니스 테스트.
bperhaps 1e7030f
test(kitchenpos): fixture 패키지 이동.
bperhaps 99a2fcb
test(kitchenpos): 상품 생성 테스트 작성.
bperhaps 8ad0b7e
test(kitchenpos): testGlue 다중 파라메터 지원.
bperhaps 8efcf13
test(kitchenpos): 상품 테스트 구현.
bperhaps 960784d
docs(kitchenpos): readme 업데이트.
bperhaps 3259c68
test(kitchenpos): 메뉴 그룹 테스트 생성.
bperhaps a88fc1c
test(kitchenpos): 깨지느 테스트 fix
bperhaps d5b5817
test(kitchenpos): menu 테스트 작성.
bperhaps 7ab55fd
test(kitchenpos): orderTable test 작성.
bperhaps 0859bd6
test(kitchenpos): order test 작성.
bperhaps ffeb412
test(kitchenpos): order table clear 테스트 구현.
bperhaps 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 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
39 changes: 39 additions & 0 deletions
39
src/test/java/kitchenpos/application/MenuGroupServiceTest.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,39 @@ | ||
package kitchenpos.application; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import kitchenpos.configuration.TestIsolationSupport; | ||
import kitchenpos.util.testglue.EnableTestGlue; | ||
import kitchenpos.util.testglue.TestGlue; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
|
||
@EnableTestGlue | ||
@SpringBootTest | ||
class MenuGroupServiceTest extends TestIsolationSupport { | ||
|
||
@Autowired | ||
private TestGlue testGlue; | ||
|
||
@DisplayName("메뉴그룹을 생성한다.") | ||
@Test | ||
void create() { | ||
testGlue.builder() | ||
.given("'추천메뉴그룹' 메뉴그룹 데이터를 만들고") | ||
.when("'추천메뉴그룹' 메뉴그룹 생성을 요청하면") | ||
.then("'추천메뉴그룹' 메뉴그룹이 생성된다") | ||
.assertStart(); | ||
} | ||
|
||
@DisplayName("메뉴그룹 이름은 비어있을 수 없다.") | ||
@Test | ||
void create_emptyName() { | ||
testGlue.builder() | ||
.given("'이름이 빈 메뉴그룹' 메뉴그룹 데이터를 만들고") | ||
.when("'이름이 빈 메뉴그룹' 메뉴그룹 생성을 요청하면") | ||
.then("'이름이 빈 메뉴그룹' 메뉴그룹 생성에 실패한다") | ||
.assertStart(); | ||
} | ||
} |
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.
사람마다 생각하는건 다르겠지만 일단 저도 인수 테스트만을 이용해 도메인 보호의 역할을 훌륭하게 수행할 수 있느냐? 라는 질문에 대해서는 의문이 있습니다. 인수 테스트가 아닌 통합 테스트 또한 마찬가지라고 생각해요.
이렇게 생각하는 이유는 인수 테스트든 통합 테스트든 하위 레이어의 도메인 모델이나 도메인 서비스 등 모든 부분에 대해 테스트 케이스를 작성하고 검증하는게 어렵다고 생각하기 때문이에요.
아무리 테스트를 꼼꼼히 잘 작성해도 인수 테스트, 통합 테스트 정도의 범위에서 바라보면 엣지 케이스를 누락할 수 있으며 또한 레이어 별로 달라지는 브랜치(if, else)에 따라 테스트 케이스가 너무 많아질 수 있습니다.
결국 인수 테스트든 통합 테스트든 위와 같은 문제 때문에 도메인의 모든 상황을 잘 커버할 수 없습니다.
인수 테스트와 통합 테스트가 쓸모없다는 얘길 하고 싶었던 건 아니에요, 당연한 이야기겠지만 도메인 로직, 클래스나 메소드 단위로 단위 테스트를 꼼꼼히 잘 작성하고 레이어 별 슬라이스 테스트를 잘 작성해주는게 중요하다는 말씀을 드리고 싶었어요.
단위 테스트가 꼼꼼히 작성된 이후 필요한 시나리오에 따라 통합 테스트나 인수 테스트를 추가해주시면 도메인 보호의 역할을 훌륭하게 수행할 수 있을거라 생각합니다.