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

[#20] 단위테스트 #31

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

[#20] 단위테스트 #31

wants to merge 5 commits into from

Conversation

nodobi
Copy link
Contributor

@nodobi nodobi commented Jun 8, 2024

👻 이슈

✍️ 공부 내용 적어주세요.

JUnit 의 기본적인 사용법과 LiveData 와 같은 Android Component 의 테스트에 대해서 공부해보았습니다

🦖 이슈가 있었다면 적어주세요.

테스트를 위한 의존성이 너무 많아서 어떤걸 추가해야 하는지 너무 헷갈렸어요.
testImplementandroidTestImplement 을 혼동해서 적기도 했었네요.. .😅

🦖 리뷰어에게 할말 적어주세요.

기존 이슈에선 3가지를 선정해서 하자고 했는데 뷰모델 테스트를 해보고 싶은 나머지.. 한 개밖에 못했습니다 ㅜㅜ
또 LiveData 테스트에서 viewModelScope 내부에서 실행한 코드들은 테스트를 못했는데 관련해서 얘기해주시면 감사하겠습니다~

++ 기존 프로젝트에서 진행해야 했는데 저 혼자만 다른 프로젝트에서 했네요..? ㅋㅋㅋ쿠ㅜㅜ 나중에 여유될 때 하나로 합쳐둘게요..

👀 참조 레퍼런스

Codelabs - Advanced Andriod in Kotlin=

@nodobi nodobi added 🍏 안드로이드 Android Skill 🐈 도혁 김도혁입니다. 😑 보통 흐음.. 😶‍🌫️ 미흡 숨어야지.. labels Jun 8, 2024
@nodobi nodobi self-assigned this Jun 8, 2024
Copy link
Contributor

@Jokwanhee Jokwanhee left a comment

Choose a reason for hiding this comment

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

고생하셨습니다.

ViewModel 단위 테스트까지 하시다니...

* - 만 61세 이상용 노인 티켓 가격 20달러. 영화 관람자의 최대 연령을 만 100세로 가정
* - -1 값은 사용자가 연령 분류에 속하지 않는 연령을 입력하는 경우 유효하지 않은 가격을 표시
*/
fun ticketPrice(age: Int, isMonday: Boolean): Int {
Copy link
Contributor

Choose a reason for hiding this comment

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

age 가 0 또는 음수라면 어떻게 되나요?

*/
class TheaterUtilUnitTest {
@Test
fun given_월요일이고12세_when_티켓가격_then_15달러() {
Copy link
Contributor

Choose a reason for hiding this comment

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

given_when_then 규칙에 맞춰주는 센스 굳굳 👍

* InstantTaskExecutorRule : Android Components 의 작업들을 모두 한 스레드에서 동작하도록 하는 Rule
*/
@get:Rule
val instantExecutorRule = InstantTaskExecutorRule()
Copy link
Contributor

Choose a reason for hiding this comment

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

처음보는 Rule... 나중에 무슨 역할인지 상세히 알려주세요 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍏 안드로이드 Android Skill 🐈 도혁 김도혁입니다. 😑 보통 흐음.. 😶‍🌫️ 미흡 숨어야지..
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[JUnit] 단위 테스트
2 participants