I am trying to test my recyclerView which and I'm using material card view for items display, and while the app works fine, i get this error when I'm trying to test:
android.view.InflateException: Binary XML file line #11: Binary XML file line #11: Error inflating class com.google.android.material.card.MaterialCardView
Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class com.google.android.material.card.MaterialCardView
Caused by: java.lang.reflect.InvocationTargetException
...
Caused by: java.lang.IllegalArgumentException: The style on this component requires your app theme to be Theme.MaterialComponents (or a descendant).
now the test is as simple as it gets:
@Test
fun shouldShowList() {
launchFragmentInContainer<PostsFragment>()
Thread.sleep(5000)
}
the sleep is only for the app to wait to try to show the list. and the strange part is when I don't use materialCardView for my list item layout, the test passes. Now I have changed my app theme to this:
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
but the test still fades, so How can I change the test theme of my app?