Skip to content

Conversation

AlexzPurewoko
Copy link
Member

This pull request for update and adding favorite movies for projects 10-room-test until 12-pagination-test.

Copy link
Member

@alfianyusufabdullah alfianyusufabdullah left a 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]
Copy link
Member

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

Copy link
Member Author

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 ?

Comment on lines 57 to 64
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
Copy link
Member

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.

Copy link
Member Author

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)
Copy link
Member

Choose a reason for hiding this comment

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

avoid using !!

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.

2 participants