Android Cucumber UI test problem with com.google.android.material

29 Views Asked by At

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).

1

There are 1 best solutions below

0
MeNoVa On

I just had to define R.style.Theme for the launchFragmentInContainer :)

launchFragmentInContainer(themeResId = R.style.Theme)