Comments (5)
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.
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.
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.
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.
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)
- java.lang.ClassNotFoundException: Didn't find class "org.easymock.IArgumentMatcher" on path HOT 1
- ActivityScenario "close()" doesn't work as expected HOT 3
- Feature request: improve error message when Espresso `Intent` matching fails due to mismatched `Intent` `data`
- launchFragmentInContainer does not work with MenuProvider HOT 1
- Orchestrator sometimes runs all the instances of a parameterized test in the same process
- Allow recording Espresso tests when app has native code HOT 3
- Synchronization capabilities: allow to wait for a View or Fragment to exist HOT 1
- Tasks not cleaned up after `ActivityScenario.launch` HOT 6
- Crash: NoSuchMethodError (handleException) in Kotlin.coroutines.CoroutineExceptionHandler in android.test.tools.crawler HOT 2
- Support minification with better consumer proguard rules HOT 3
- androidx.test:runner uses junit 4.12 whic his affected by CVE-2020-15250 HOT 2
- Connect to my electronic victimizers HOT 1
- Android Test Report Merging Not Working HOT 2
- Espresso's `ViewActions.click()` appears to be flaky HOT 5
- Can't start implicit `Intent` from `ActivityScenario#launchActivityForResult` when targeting API 34 HOT 4
- Espresso ViewActions.swipeRight doesn't work for ViewPager2 on device with API 32+ HOT 1
- Unresolved reference: FragmentScenarioEmptyFragmentActivityTheme HOT 1
- Instrumentation command failed with non zero exit code when use Gradle Managed Devices HOT 1
- Feature Request: Support fail-fast for AndroidJUnitRunner HOT 3
- NoMethodFound crashes with new beta01 releases HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from android-test.