paparazzi icon indicating copy to clipboard operation
paparazzi copied to clipboard

Cannot inflate fragments using custom UI components

Open malik-hasan opened this issue 1 year ago • 2 comments

Description I've been trying to write tests for fragments that use viewbinding, but I see this error whenever I test a fragment which uses custom UI components inside of it. Testing the cards individually works no problem.

app.cash.paparazzi.internal.PaparazziLogger$MultipleFailuresException: There were 4 errors:

  android.view.InflateException: Binary XML file line #23: Error inflating class com.example.app.views.CustomCard1

  android.view.InflateException: Binary XML file line #31: Error inflating class com.example.app.views.CustomCard2

  android.view.InflateException: Binary XML file line #47: Error inflating class com.example.app.views.CustomCard3

  android.view.InflateException: Binary XML file line #55: Error inflating class com.example.app.views.CustomCard4

Steps to Reproduce

  1. Create fragment with viewbinding which uses a custom UI view inside of it
  2. In my case the custom UI view extends FrameLayout. I have a custom component which extends RecyclerView which does not cause issues
  3. Try to record snapshot of the fragment The syntax I am using is
val view: View = paparazzi.inflate(R.layout.fragment)
paparazzi.snapshot(view)

I tried this method with binding as well but it did not work with any of the views at all.

val binding = FragmentBinding.inflate(paparazzi.layoutInflater)
paparazzi.snapshot(binding.root)

Expected behavior Snapshot is recorded

Additional information:

  • Paparazzi Version: 1.3.1
  • OS: MacOS 13.5.1
  • Compile SDK: 33
  • Gradle Version: 8.1.1
  • Android Gradle Plugin Version: 8.0.2

Screenshots n/a

malik-hasan avatar Aug 31 '23 18:08 malik-hasan