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

학습 테스트 실습 리뷰 부탁드립니다 #1843

Merged
merged 1 commit into from Mar 2, 2021

Conversation

loop-study
Copy link

안녕하세요 박현철입니다
테스트코드 미숙해서 제대로 했는지 모르겠습니다
수정사항 부탁드립니다
감사합니다

Copy link

@changgunyee changgunyee left a comment

Choose a reason for hiding this comment

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

안녕하세요😄
자동차 미션 함께하게 된 이창권입니다.
테스트 코드 잘 작성해 주셨네요👍

다음 단계 진행을 위해 바로 머지하겠습니다.
궁금한점이나, 어려운점 있으면 슬랙을 통하여 DM 주세요. 함께 고민해보아요.🔥
앞으로 미션도 화이팅 입니다!

@DisplayName("문자열 1,2 나누기")
public void stringTest01() throws Exception {
String[] result = "1,2".split(",");
// assertThat(result).contains("1", "2");

Choose a reason for hiding this comment

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

의미있는 주석이 아니라면 웬만하면 삭제하여주세요!

Copy link
Author

Choose a reason for hiding this comment

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

의미없는 주석은 삭제하겠습니다

public void stringTest03() throws Exception {
String data = "(1,2)";
String result = data.substring(1, data.length()-1);
assertThat(result).isEqualTo("1,2");

Choose a reason for hiding this comment

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

잘 작성하셨네요 💯

추가로 아래처럼 given, when, then 순으로 작성하시면
좀 더 가독성 및 Test 코드를 보고 의도를 파악하기 쉽습니다.😄

// given
String data = "(1,2)";

// when
String result = data.substring(1, data.length()-1);

// then
assertThat(result).isEqualTo("1,2");

Copy link
Author

Choose a reason for hiding this comment

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

given, when, then 템플릿으로 진행하겠습니다

assertThatThrownBy(() -> {
data.charAt(3);
}).isInstanceOf(IndexOutOfBoundsException.class)
.hasMessageContaining("String index out of range: 3");

Choose a reason for hiding this comment

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

예외 테스트도 잘 작성하여주셨습니다!

Copy link
Author

Choose a reason for hiding this comment

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

예외테스트 경우엔 실패할 에러메시지까지 일치시켜야 되는건가요?
아니면 예외처리안에서 에러가 발생하면 통과인지 궁금합니다.

}

@Test
@DisplayName("Set size 확인")

Choose a reason for hiding this comment

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

@DisplayName 으로 어떠한 테스트 인지 파악할 수 있어 좋네요 💯

메소드 이름이나 @DisplayName이 어느 정도까지 구체적이어야 하는지에 대해서 정답은 없다고 생각합니다.
다만, 이름만으로도 언제 이 메서드를 호출해야 하는지 또 어떤 테스트를 하는 것인지 의미를 파악할 수 있도록 작성하시면 다른 사람이 볼때도 쉽게 의도를 파악할 수 있을거 같네요. 아래 자료도 참고해 보시면 좋을거 같아요. 👍

https://woowacourse.github.io/javable/2020-04-26/Method-Naming

Copy link
Author

Choose a reason for hiding this comment

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

해당 링크 404 뜨고 있습니다... ㅜㅜㅜㅜㅜ

Copy link
Author

Choose a reason for hiding this comment

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


@Test
@DisplayName("Set size 확인")
public void setTest01() throws Exception {

Choose a reason for hiding this comment

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

물론 DisplayName으로 어떤 테스트인지 파악할 수 있지만 함수명도 어떤 의미의 테스트인지 담을 수록 좋습니다.
다음 단계부터는 함수명도 의미있는 이름으로 바꿔보도록 해요!

Copy link
Author

Choose a reason for hiding this comment

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

함수명... 변수명...
이름짓기가 너무 힘드네요😂
https://www.curioustore.com/#!/
사이트의 도움을 받아야겠습니다.

public void setTest03(int inputNumber, boolean isFree) throws Exception {
assertThat(numbers.contains(inputNumber)).isEqualTo(isFree);
}
}

Choose a reason for hiding this comment

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

커밋 로그를 의미있는 단위로 나눠주시면 좋습니다.
또한 메시지에 로그 타입도 같이 작성해주시면 좋을거 같아요 👍

feat (feature)
fix (bug fix)
docs (documentation)
style (formatting, missing semi colons, …)
refactor
test (when adding missing tests)
chore (maintain)

아래 링크 참고하셔서 미션 수행시 기능 단위로 Commit Log 남길때 참고해보시면 좋을거 같아요 😄
https://gist.github.com/stephenparish/9941e89d80e2bc58a153

Copy link
Author

Choose a reason for hiding this comment

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

커밋 컨벤션 처음 알았네요!
커밋로그에 맞게 남기곘습니다👍

@changgunyee changgunyee merged commit e7fe337 into next-step:loop-study Mar 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants