Code Monkey home page Code Monkey logo

Comments (5)

brettchabot avatar brettchabot commented on July 17, 2024

Without a complete sample it will be difficult to provide guidance here. Is it possible to build a repro case using https://github.com/android/testing-samples/tree/main/ui/espresso/BasicSample as a baseline?

from android-test.

albertB4work avatar albertB4work commented on July 17, 2024

What more do you need? You have the code for the test class. when y click to launch the test file it shows the other errors. I cannot build a repro case because i'm in a professional complex project. But HomeActivity inherits from

class HomeActivity : BasePresenterActivity<HomeActivityPresenter>(), BottomNavigator, NotificationManager.InAppNotificationInterface, INotificationView, HomeActivityPresenter.Contract, CustomInAppMessaging.InAppNotificationInterface, ChannelSelectorFragment.ChannelSelectorFragmentInteractionListener

abstract class BasePresenterActivity<P : RPresenter<*, *>> : BaseActivity() {

abstract class BaseActivity : AppCompatActivity()

The test class:

@RunWith(AndroidJUnit4::class)
class FiltersFragmentTest {

    @get:Rule
    val sc: ActivityScenario<HomeActivity> = ActivityScenario.launch(HomeActivity::class.java)

    @Before
    fun enterToFilterScreenFromFeed() {
        onView(withId(R.id.iv_filter)).perform(click())
        EspressoIdle.increment()
    }


    @Test
    fun ifSearchTextPresentAppbarRestoreTextShown() {
        onView(withId(R.id.etSearch))
            .check(matches(withParent(withId(R.id.searchInput))))
            .perform(replaceText("A")).perform(closeSoftKeyboard())
        onView(withId(R.id.tv_rightText))
            .check(matches(isDisplayed()))
    }
}

from android-test.

albertB4work avatar albertB4work commented on July 17, 2024

If y want to execute a test class with launchFragmentContainer from fragment scenario also complains that the generic class passed is not an instance of Fragment, and it is

from android-test.

albertB4work avatar albertB4work commented on July 17, 2024

I also tried to inherit directly from Fragment() and the import is correct androidx.fragment.app.Fragment

Same errors:
> Task :app:compileDebugAndroidTestKotlin FAILED e: file:///C:/Users/Usuario/Projectes/b4work-android/app/src/androidTest/kotlin/com/innopro/b4work/FiltersFragmentTest.kt:12:47 Type argument is not within its bounds: should be subtype of 'Fragment' e: file:///C:/Users/Usuario/Projectes/b4work-android/app/src/androidTest/kotlin/com/innopro/b4work/FiltersFragmentTest.kt:16:31 Cannot access class 'androidx.fragment.app.FragmentFactory'. Check your module classpath for missing or conflicting dependencies e: file:///C:/Users/Usuario/Projectes/b4work-android/app/src/androidTest/kotlin/com/innopro/b4work/FiltersFragmentTest.kt:16:49 Type mismatch: inferred type is FiltersFragment but Fragment was expected

from android-test.

albertB4work avatar albertB4work commented on July 17, 2024

The new code for the test class

package com.my.package

import androidx.fragment.app.testing.FragmentScenario
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.innopro.b4work.newcode.presentation.filterview.FiltersFragment
import org.junit.Before
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class FiltersFragmentTest {

    private lateinit var sc: FragmentScenario<FiltersFragment>

    @Before
    fun setup() {
        sc = FragmentScenario.launchInContainer(FiltersFragment::class.java)
    }
}

from android-test.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.