Skip to content
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

[2단계 - 자동차 경주 리팩토링] 연로그(권시연) 미션 제출합니다. #419

Merged
merged 20 commits into from
Feb 22, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/java/racingcar/view/InputView.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ public class InputView {

public static String inputCarNames() {
System.out.println(NoticeMessages.INPUT_CAR_NAMES);
return scanner.next();
return scanner.nextLine();
}

public static String inputTryCount() {
System.out.println(NoticeMessages.INPUT_TRY_CNT);
return scanner.next();
return scanner.nextLine();
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 부분을 수정을 했었는데 PR 충돌 해결하면서 코드가 다시 바뀌었던 것 같아요

사용자가 직접 입력하는 값도 테스트를 할 수 있나요?
할 수 있다면 어떤 방법을 사용할까요?
처음엔 전략 패턴을 적용시키면 가능할까해서 만들어보다가 그냥 문자열에 대한 테스트가 될뿐 사용자가 의도한대로 입력이 되었는지에 대한 테스트가 아닌 것 같아서 롤백했습니다.😭

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

연로그가 이끌어낸 결론이 제가 생각한 질문이었어요🙂

사용자가 직접 입력하는 것은 우리가 제어할 수 있는 대상이 아니니 테스트 대상이 아니라고 판단하는게 맞을 것 같아요. 그렇다면 우리가 제어할 수 없는 사용자 입력을 어떻게 제어할 수 있는 범위로 넣을 것인가?를 고민했을 때 전략패턴으로 이를 해결할 수 있구요.

다만 연로그가 말한 것 처럼 사용자가입력한 값 == 문자열에 대한 테스트가 될 확률이 높겠죠? 그렇기에 불필요하다면 추가하지 않는 것도 방법이에요.

조금 더 나아가서 프로그램 전체가 올바르게 동작한다 즉 레이싱컨트롤러.start()를 했을 때 전체 프로그램이 동작한다를 증명하려면 입력에 대한 전략패턴이 분명 필요해질 수 있겠죠? 어떤 것을 테스트할 것인가에 따라 전략패턴도, 다른 기법들도 사용될지 아닐지가 달라질 수 있다는 점까지 염두해두면 더 좋을 것 같습니다🙂

}
}