Android Clean Architecture
Testing the Configuration DAO
Up next
Previous
About
The Presentation layer allows us to abstract the presentation logic from the framework specific implementation of our user interface. In this lesson, we'll be creating the test for the Configuration DAO so that its implementation behaves as expected throughout our projects lifetime.
Instructor
Links
Comments
sorry , but i have an error and i can't fix it :
when i try to pass this test case it fail :-
@Test
fun saveConfigurationSavesData() {
val config = ConfigDataFactory.makeCachedConfig()
database.configDao().insertConfig(config)
val testObserver = database.configDao().getConfig().test()
testObserver.assertValue(config)
}
and this is error :-
java.lang.AssertionError: Expected: com.example.cache.model.Config@34780cd9 (class: Config), Actual: com.example.cache.model.Config@623ebac7 (class: Config) (latch = 0, values = 1, errors = 0, completions = 1)
can u explain why it fail and how can i fix it , please?
Hello, probably the error you guys mention is due to object comparison.
Under the hood, assertValue() uses the equals() method of the class being returned, in this case, that's "com.example.cache.model.Config". So make sure that this class is a kotlin data class. If not, check if the equals() method is implemented correctly in that class.
Bernat
Lessons in Android Clean Architecture















































































