Skip to content

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

@albertB4work

Description

@albertB4work

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions