Group Group Group Group Group Group Group Group Group

Problem with testing Fragments in AndroidX

#1

Hi all

I am trying to test Fragments with AndroidX test libraries (especially with FragmentScenario class)
I have a problem - all the test with fragments created with FragmentScenarion are getting stuck and not showing on the screen.
Does anyone know how to solve it?

P. S. All tests failed with the error - “java.lang.AssertionError: Activity never becomes requested state “[DESTROYED, RESUMED, STARTED, CREATED]” (last lifecycle transition = “PRE_ON_CREATE”)”

Thanks in advance

#2

@macsimus Can you please help with this when you get a chance? Thank you - much appreciated! :]

#3

I had the same issue.
The problem seems to be that I was using

androidTestImplementation 'androidx.fragment:fragment-testing:1.1.0-alpha06'

instead of

debugImplementation 'androidx.fragment:fragment-testing:1.1.0-alpha06'

like in the sample code

With debugImplementation it is working for me.

#4

@vapillon Glad you sorted it out! Cheers! :]

closed #5

This topic was automatically closed after 166 days. New replies are no longer allowed.