Android Clean Architecture
Testing the data store factory class
Up next
Previous
About
The Data layer uses a data store factory to abstract the source of the data that our application uses from the repository that we use to access data. In this lesson, we're going to be writing some tests to ensure that the correct factory classes are returned when requested.
Instructor
Links
Comments
Hello Joe, Can we use this?
private lateinit var factory:ProjectsDataStoreFactory
@Mock
lateinit var cacheStore:ProjectsCacheDataStore
@Mock
lateinit var remoteStore:ProjectsRemoteDataStore
@Before
fun setup(){
MockitoAnnotations.initMocks(this)
factory = ProjectsDataStoreFactory(cacheStore,remoteStore)
}
yes you can do it
but you will get an error
Mockito cannot mock/spy following:
– final classes
to fix it you’ll need to create a file in the test/resources/mockito-extensions folder called org.mockito.plugins.MockMaker
and you have to write this line
mock-maker-inline
reference : https://antonioleiva.com/mockito-2-kotlin/
yes u can. and mockito doesnt work with final classes but mockito 2 does. If you guys are facing any issues with this test and don't know about this fix, goto :https://stackoverflow.com/questions/14292863/how-to-mock-a-final-class-with-mockito
Answers are there. :)
Lessons in Android Clean Architecture















































































