Verifique a visibilidade do fragmento depois de clicar na guia TabLayout que contém apenas o ícone usando o Android Espresso

Estou tentando verificar se meu fragmento está visível depois de clicar na minha guia do meu tabLayout, que foi configurado com o modo de exibição pager.

Este é o meu código de atividade real, dentro do meu método onCreate de atividade:

mViewPager = findViewById(R.id.contentFrameLayout);
mViewPager.setAdapter(mSectionPageAdapter);
mViewPager.setPagingEnabled(false);

//Set up the tab layout to display tabs
tabLayout = findViewById(R.id.homeTabs);
tabLayout.setupWithViewPager(mViewPager);

for (int i = 0; i< tabLayout.getTabCount(); i++) {
        TabLayout.Tab mTab = tabLayout.getTabAt(i);
        if (mTab != null) {
            switch (i){
                case 0:
                    mTab.setTag(WFragment.class.toString());
                    mTab.setIcon(R.drawable.home_icon_svg);
                    break;
                case 1:
                    mTab.setTag(MFragment.class.toString());
                    mTab.setIcon(R.drawable.l_svg);
                    break;
                case 2:
                    //etc..
            }
        }
    }

Aqui está o meu teste de instrumentação:

@Test
public void checkIfMFragmentIsVisible() {
    Matcher<View> matcher = allOf(withTagValue(is((Object) MFragment.class.toString())),
            isDescendantOfA(withId(R.id.homeTabs)));
    onView(matcher).perform(click());
    onView(withId(R.id.mFragmentLayout)).check(matches(isCompletelyDisplayed()));
}

Eu usei informações deesta link que me ajudou a começar a criar um matcher e a executar um clique. No entanto, meu teste está falhando com o seguinte erro:

android.support.test.espresso.NoMatchingViewException: No views in hierarchy found matching: (with tag value: is "class com.test.solution.fragments.MFragment" and is descendant of a: with id: 2131296345)
If the target view is not part of the view hierarchy, you may need to use Espresso.onData to load it from one of the following AdapterViews:com.google.maps.api.android.lib6.impl.ce{d55b63a G.ED..C.. ......I. 0,0-0,0}

TESTE DE INSTRUMENTAÇÃO DE SUCESSO:

Eu tentei um teste simulado adicionando o seguinte emminhas guias na minha atividade:

TabLayout.Tab mTab = tabLayout.getTabAt(i);
            if (mTab != null) {
                switch (i){
                    case 0:
                        mTab.setText("case 0");
                        //etc..
                    case 1:
                        mTab.setText("case 1");
                        //etc..
                    case 2:
                        //etc..

E no meu teste de instrumentação:

@Test
public void checkIfMFragmentIsVisible() {
    Matcher<View> matcher = allOf(withText("case 1"),
                isDescendantOfA(withId(R.id.homeTabs)));
        onView(matcher).perform(click());
        onView(withId(R.id.mFragmentLayout)).check(matches(isCompletelyDisplayed()));
}

Este teste foi bem-sucedido, no entanto, não quero usar um texto em minha atividade, mas quero usar uma tag ou outra coisa.

questionAnswers(1)

yourAnswerToTheQuestion