I wrote a test scenario with the help of Cucumber and espresso and when I run the test it crashes wherever I use the com.google.android.material library.
For example :
com.google.android.material.appbar.AppBarLayout , com.google.android.material.button.MaterialButton
Error :
android.view.InflateException: Binary XML file line # in layout/fragment_layout: Error inflating class com.google.android.material.button.MaterialButton
Cucumber or espresso seems to have a problem with the material library.
I ran my test with this command :
./gradlew connectedMyFlavorAndroidTest -Pcucumber -Pscenario="My Scenario"
and it crashed wherever there was a material library in UI(xml layout).
I just had to define R.style.Theme for the launchFragmentInContainer :)