paparazzi
paparazzi copied to clipboard
Cannot inflate fragments using custom UI components
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
- Create fragment with viewbinding which uses a custom UI view inside of it
- In my case the custom UI view extends FrameLayout. I have a custom component which extends RecyclerView which does not cause issues
- 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