Не найдено подходящих представлений в иерархии: с идентификатором / recyclerView в эспрессо - PullRequest
0 голосов
/ 27 октября 2019

Я занимаюсь разработкой приложения, и я внедрил тестирование, когда пользователь нажимает на ссылку recyclerview. Оно должно запускаться, но когда я запускаю эспрессо-тестирование, я получаю ниже исключения

Runner: failed: testRecyclerView(yodgorbek.komilov.musobaqayangiliklari.RecyclerViewTest)
    ----- begin exception -----
E/TestRunner: androidx.test.espresso.NoMatchingViewException: No views in hierarchy found matching: with id: yodgorbek.komilov.musobaqayangiliklari:id/recyclerView

    View Hierarchy:
    +>DecorView{id=-1, visibility=VISIBLE, width=1080, height=1920, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params={(0,0)(fillxfill) ty=BASE_APPLICATION wanim=0x10302fe
      fl=LAYOUT_IN_SCREEN LAYOUT_INSET_DECOR SPLIT_TOUCH HARDWARE_ACCELERATED DRAWS_SYSTEM_BAR_BACKGROUNDS
      pfl=FORCE_DRAW_STATUS_BAR_BACKGROUND}, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=3} 
    |
    +->LinearLayout{id=-1, visibility=VISIBLE, width=1080, height=1794, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params=android.widget.FrameLayout$LayoutParams@68a7071, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=2} 
    |
    +-->ViewStub{id=16908692, res-name=action_mode_bar_stub, visibility=GONE, width=0, height=0, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=true, is-selected=false, layout-params=android.widget.LinearLayout$LayoutParams@f9a7e56, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0} 
    |
    +-->FrameLayout{id=-1, visibility=VISIBLE, width=1080, height=1731, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params=android.widget.LinearLayout$LayoutParams@8a5a3c4, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=63.0, child-count=1} 
    |
    +--->FitWindowsLinearLayout{id=2131230762, res-name=action_bar_root, visibility=VISIBLE, width=1080, height=1731, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params=android.widget.FrameLayout$LayoutParams@f18e173, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=2} 
    |
    +---->ViewStubCompat{id=2131230773, res-name=action_mode_bar_stub, visibility=GONE, width=0, height=0, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=true, is-selected=false, layout-params=android.widget.LinearLayout$LayoutParams@43b3830, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0} 
    |
    +---->ContentFrameLayout{id=16908290, res-name=content, visibility=VISIBLE, width=1080, height=1731, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params=android.widget.LinearLayout$LayoutParams@e53022e, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=1} 
    |
    +----->ConstraintLayout{id=-1, visibility=VISIBLE, width=1080, height=1731, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params=android.widget.FrameLayout$LayoutParams@911133a, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=2} 
    |
    +------>Toolbar{id=2131230984, res-name=toolbar, visibility=VISIBLE, width=1080, height=0, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params=androidx.constraintlayout.wi
    ----- end exception -----
I/TestRunner: finished: testRecyclerView(yodgorbek.komilov.musobaqayangiliklari.RecyclerViewTest)

androidx.test.espresso.NoMatchingViewException: No views in hierarchy found matching: with id: yodgorbek.komilov.musobaqayangiliklari:id/recyclerView

View Hierarchy:
+>DecorView{id=-1, visibility=VISIBLE, width=1080, height=1920, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params={(0,0)(fillxfill) ty=BASE_APPLICATION wanim=0x10302fe
fl=LAYOUT_IN_SCREEN LAYOUT_INSET_DECOR SPLIT_TOUCH HARDWARE_ACCELERATED DRAWS_SYSTEM_BAR_BACKGROUNDS
pfl=FORCE_DRAW_STATUS_BAR_BACKGROUND}, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=3}
|
+->LinearLayout{id=-1, visibility=VISIBLE, width=1080, height=1794, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params=android.widget.FrameLayout$LayoutParams@68a7071, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=2}
|
+-->ViewStub{id=16908692, res-name=action_mode_bar_stub, visibility=GONE, width=0, height=0, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=true, is-selected=false, layout-params=android.widget.LinearLayout$LayoutParams@f9a7e56, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0}
|
+-->FrameLayout{id=-1, visibility=VISIBLE, width=1080, height=1731, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params=android.widget.LinearLayout$LayoutParams@8a5a3c4, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=63.0, child-count=1}
|
+--->FitWindowsLinearLayout{id=2131230762, res-name=action_bar_root, visibility=VISIBLE, width=1080, height=1731, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params=android.widget.FrameLayout$LayoutParams@f18e173, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=2}
|
+---->ViewStubCompat{id=2131230773, res-name=action_mode_bar_stub, visibility=GONE, width=0, height=0, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=true, is-selected=false, layout-params=android.widget.LinearLayout$LayoutParams@43b3830, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0}
|
+---->ContentFrameLayout{id=16908290, res-name=content, visibility=VISIBLE, width=1080, height=1731, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params=android.widget.LinearLayout$LayoutParams@e53022e, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=1}
|
+----->ConstraintLayout{id=-1, visibility=VISIBLE, width=1080, height=1731, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params=android.widget.FrameLayout$LayoutParams@911133a, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=2}
|
+------>Toolbar{id=2131230984, res-name=toolbar, visibility=VISIBLE, width=1080, height=0, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params=androidx.constraintlayout.widget.ConstraintLayout$LayoutParams@86d2906, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=3}
|
+------->AppCompatTextView{id=-1, visibility=VISIBLE, width=275, height=0, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params=androidx.appcompat.widget.Toolbar$LayoutParams@99e7bc7, tag=null, root-is-layout-requested=false, has-input-connection=false, x=189.0, y=10.0, text=Sport News, input-type=0, ime-target=false, has-links=false}
|
+------->AppCompatImageButton{id=-1, desc=Navigate up, visibility=VISIBLE, width=147, height=0, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=true, is-enabled=true, is-focused=false, is-focusable=true, is-layout-requested=false, is-selected=false, layout-params=androidx.appcompat.widget.Toolbar$LayoutParams@51b85f4, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0}
|
+------->ActionMenuView{id=-1, visibility=VISIBLE, width=0, height=0, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params=androidx.appcompat.widget.Toolbar$LayoutParams@e40911d, tag=null, root-is-layout-requested=false, has-input-connection=false, x=1080.0, y=0.0, child-count=0}
|
+------>WebView{id=2131230782, res-name=article, visibility=VISIBLE, width=1080, height=1731, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=true, is-enabled=true, is-focused=true, is-focusable=true, is-layout-requested=false, is-selected=false, layout-params=androidx.constraintlayout.widget.ConstraintLayout$LayoutParams@722cf92, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=0}
|
+->View{id=16908336, res-name=navigationBarBackground, visibility=VISIBLE, width=1080, height=126, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params=android.widget.FrameLayout$LayoutParams@1fd0d63, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=1794.0}
|
+->View{id=16908335, res-name=statusBarBackground, visibility=VISIBLE, width=1080, height=63, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params=android.widget.FrameLayout$LayoutParams@650d60, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0}
|
at dalvik.system.VMStack.getThreadStackTrace(Native Method)
at java.lang.Thread.getStackTrace(Thread.java:1720)
at androidx.test.espresso.base.DefaultFailureHandler.getUserFriendlyError(DefaultFailureHandler.java:94)
at androidx.test.espresso.base.DefaultFailureHandler.handle(DefaultFailureHandler.java:57)
at androidx.test.espresso.ViewInteraction.waitForAndHandleInteractionResults(ViewInteraction.java:316)
at androidx.test.espresso.ViewInteraction.desugaredPerform(ViewInteraction.java:177)
at androidx.test.espresso.ViewInteraction.perform(ViewInteraction.java:118)
at yodgorbek.komilov.musobaqayangiliklari.RecyclerViewTest.testRecyclerView(RecyclerViewTest.kt:47)
at java.lang.reflect.Method.invoke(Native Method)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at androidx.test.runner.AndroidJUnit4.run(AndroidJUnit4.java:104)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:56)
at androidx.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:388)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2189)

I/MonitoringInstr: Activities that are still in CREATED to STOPPED: 1
    Finishing activity: yodgorbek.komilov.musobaqayangiliklari.ui.detail.DetailActivity@b17f212
D/LifecycleMonitor: Lifecycle status change: yodgorbek.komilov.musobaqayangiliklari.ui.detail.DetailActivity@b17f212 in: PAUSED
    running callback: androidx.test.rule.ActivityTestRule$LifecycleCallback@efd9f8c
    callback completes: androidx.test.rule.ActivityTestRule$LifecycleCallback@efd9f8c
I/MonitoringInstr: Unstopped activity count: 1
I/MonitoringInstr: Unstopped activity count: 1
I/MonitoringInstr: Unstopped activity count: 1
I/MonitoringInstr: Unstopped activity count: 1
I/MonitoringInstr: Unstopped activity count: 1
I/MonitoringInstr: Unstopped activity count: 1
I/chatty: uid=10134(yodgorbek.komilov.musobaqayangiliklari) roidJUnitRunner identical 3 lines
I/MonitoringInstr: Unstopped activity count: 1
I/MonitoringInstr: Unstopped activity count: 1
I/MonitoringInstr: Unstopped activity count: 1
I/MonitoringInstr: Unstopped activity count: 1
I/MonitoringInstr: Unstopped activity count: 1
I/MonitoringInstr: Unstopped activity count: 1
I/chatty: uid=10134(yodgorbek.komilov.musobaqayangiliklari) roidJUnitRunner identical 1 line
I/MonitoringInstr: Unstopped activity count: 1
I/MonitoringInstr: Unstopped activity count: 1
I/MonitoringInstr: Unstopped activity count: 1
I/MonitoringInstr: Unstopped activity count: 1
I/MonitoringInstr: Unstopped activity count: 1
I/MonitoringInstr: Unstopped activity count: 1
I/MonitoringInstr: Unstopped activity count: 1
E/THREAD_STATE:   Thread[Binder:30850_1,5,main]

      Thread[Jit thread pool worker thread 0,5,main]

      Thread[ReferenceQueueDaemon,5,system]
        java.lang.Object.wait(Native Method)
        java.lang.Object.wait(Object.java:442)
        java.lang.Object.wait(Object.java:568)
        java.lang.Daemons$ReferenceQueueDaemon.runInternal(Daemons.java:215)
        java.lang.Daemons$Daemon.run(Daemons.java:137)
        java.lang.Thread.run(Thread.java:919)

      Thread[CrAsyncTask #1,5,main]
        sun.misc.Unsafe.park(Native Method)
        java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:230)
        java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2109)
        java.util.concurrent.ArrayBlockingQueue.poll(ArrayBlockingQueue.java:402)
        java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1091)
        java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152)
        java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        EQ.run(Unknown Source:3)

ниже уровня My Testclass, где я реализовал свой тест спереработчик просмотра

@ RunWith (AndroidJUnit4 :: class) @ LargeTest

class RecyclerViewTest {

@Test
fun testRecyclerView() {

    var firstActivity: IntentsTestRule<DetailActivity> = IntentsTestRule(DetailActivity::class.java)
    firstActivity.launchActivity(Intent())

    firstActivity.activity.findViewById<RecyclerView>(R.id.recyclerView)

    onView(withId(R.id.recyclerView))
        .perform(RecyclerViewActions.actionOnItemAtPosition<RecyclerView.ViewHolder>(1, click()))
  //  Espresso.pressBack()

}

}

...