-
Notifications
You must be signed in to change notification settings - Fork 175
Fix and add favorite unit test #108
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
base: master
Are you sure you want to change the base?
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.
Pelajari step menentukan skenario di sini https://github.com/wajahatkarim3/Imagine
|
||
@Test | ||
fun setReadModule() { | ||
val dummy = DataDummy.generateDummyModules("a")[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.
Ini dummy cuman buat invoke sama verify? Tambahkan assertion
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.
Kalau yang ini kan yang di test method void dan hanya meneruskan call saja ke repository. Jadi menurutku, disini cukup verify call method saja
https://blog.knoldus.com/unit-testing-void-methods-with-mockito-and-junit/
Atau mungkin dari mas Alfian ada cara lain kah ?
val dummyCourseWithModule = Resource.success(DataDummy.generateDummyCourseWithModules(dummyCourse, false)) | ||
val course = MutableLiveData<Resource<CourseWithModule>>() | ||
course.value = dummyCourseWithModule | ||
|
||
`when`(academyRepository.getCourseWithModules(courseId)).thenReturn(course) | ||
viewModel.courseModule.observeForever(observer) | ||
|
||
val courseFromViewModel = viewModel.courseModule.value!!.data |
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.
Ini buat apa? Skenario berikutnya doNothing
, jadi bisa langsung pakai dummyCourseWithModule
saja.
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.
Ok mas fix it
|
||
val courseFromViewModel = viewModel.courseModule.value!!.data | ||
|
||
doNothing().`when`(academyRepository).setCourseBookmark(courseFromViewModel!!.mCourse, true) |
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.
avoid using !!
This pull request for update and adding favorite movies for projects 10-room-test until 12-pagination-test.