-
Notifications
You must be signed in to change notification settings - Fork 412
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
step3 자동차 경주 구현 #1528
base: wjddn279
Are you sure you want to change the base?
step3 자동차 경주 구현 #1528
Conversation
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.
안녕하세요 정우님 👋
3단계 미션 잘 구현해주셨습니다.
몇 가지 코멘트 남겼으니 확인해주세요~
import racingcar.view.ResultView | ||
|
||
class Racing<T: Runnable>(private val racingCarFactory: () -> T) { | ||
fun race() { |
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.
자동차 경주 단계부터는 실행할 수 있는 main 함수를 만들어주셔야합니다. 실제로 경주가 잘 되는지 확인도 해야하구요.
override fun getDistance(): Int { | ||
val randomNumber = RandomGenerator.getRandomIntNumber(RANDOM_THRESHOLD) | ||
return if (randomNumber >= 4) 1 else 0 |
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.
수업 자료나 수업 다시보기 영상을 참고해서 테스트 가능한 구조로 구현해보시면 좋을 것 같아요. 랜덤을 만들어내는 부분을 도메인 바깥으로 분리하는 게 핵심이 되겠네요.
부족한 테스트도 자연스럽게 해결될 것 같습니다.
// SystemOutExtension을 사용하여 콘솔 출력을 캡처 | ||
context("racing 통합 테스트") { | ||
val racing = Racing { RacingCar() } | ||
racing.doRacing(3, 5) |
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.
@@ -0,0 +1,9 @@ | |||
package racingcar.utils | |||
|
|||
import java.util.* |
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.
코틀린에도 Random 패키지가 존재합니다. 코틀린 과정이니만큼 코틀린 패키지를 사용해보셔도 좋을 것 같아요.
안녕하세요 진도가 늦네요~ 빠르게 잡겠습니다!
마지막 통합테스트가 조금 부실한데요 ㅠㅠ 어떻게 테스트 방향성을 잡을지 조언 부탁드립니다!