androidandroid-espressoandroid-navigationinstrumented-testandroid-splashscreen

instrumentTesting with Espresso when facing with Splash Screen API and Navigation


How to perform Instrumental Testing or Android Testing when using Splash Screen API and Navigation.

As we know, Activity is no longer needed to create splash screen, we just need to make new Theme to implement the Splash Screen API.

And for Navigation, we defined our Activity as defaultNavHost and our app interactions goes to its fragment. for example, I set my HomeActivity as my defaultNavHost and the app interactions is goes to its HomeFragment.


[PROBLEM]:
When I start to make a simple Instrumental Testing, and I run the test case, I got this error message (edited): Execution failed for task ':app:processDebugAndroidTestManifest I don't know, is it because of my test script or not.

Is there something wrong with my test code below?

@RunWith(AndroidJUnit4ClassRunner::class)
class HomeActivityTest {
    @Before
    fun setUp() {
        ActivityScenario.launch(HomeActivity::class.java)
    }

    @Test
    fun performSwipeUpRecyclerViewContainerToTop() {
        onView(withId(R.id.rv_features)).check(matches(isDisplayed()))
    }
}

EDIT:
I facing with new error, the message is like this:

* What went wrong:
Execution failed for task ':app:processDebugAndroidTestManifest'.
> Could not resolve all files for configuration ':app:debugAndroidTestRuntimeClasspath'.
   > Could not find androidx.test:rules:1.5.2.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/androidx/test/rules/1.5.2/rules-1.5.2.pom
       - https://repo.maven.apache.org/maven2/androidx/test/rules/1.5.2/rules-1.5.2.pom
       - https://jcenter.bintray.com/androidx/test/rules/1.5.2/rules-1.5.2.pom
     Required by:
         project :app

Solution

  • This problem was solve, sorry its just my fault. Even if you're using Navigation Comp and Splash Screen API, you're still be able to test your main activity.


    I'll give some review,

    1. For the first error: "STRING_TOO_LARGE", you just need to invalidate caches or restart your IDE.
    2. For the second error: "Execution failed for task ':app:processDebugAndroidTestManifest", it's because of my fault, I didn't check the test:ruler version.