testing-samples icon indicating copy to clipboard operation
testing-samples copied to clipboard

Not compiling test class with a fragment that not inherits directly but indirectly from Fragment class

Open albertB4work opened this issue 1 year ago • 0 comments

I'm working with this code:

@RunWith(AndroidJUnit4ClassRunner::class)
class FiltersFragmentTest {

    @Test
    fun fragmentIsVisible() {
        val scenario = launchFragmentInContainer<FiltersFragment>()
        scenario.recreate()
        Espresso
            .onView(ViewMatchers.withId(R.id.jvQuery))
            .check(matches(isDisplayed()))
    }
}

The FiltersFragment class inherits from a class custom, that inherits from another custom base fragment class that inherits from Fragment (androidx.fragment.app.Fragment). But when trying to execute the test an error is shown in compile time

Cannot access class 'androidx.fragment.app.FragmentFactory'. Check your module classpath for missing or conflicting dependencies Type argument is not within its bounds: should be subtype of 'Fragment'

I see in my project dependencies two versions of fragment library: 1.3.6 for appCompat library use and direct dependency 1.6.2 Both have FragmentFactory class inside

albertB4work avatar Jan 16 '24 12:01 albertB4work