mercredi 11 mars 2020

IllegalStateException in Roboelectric with SupportFragmentTestUtil.startVisibleFragment(myFragment)

I'm setting up this class for testing my fragment:

@RunWith(RobolectricTestRunner.class)
public class MyFragmentTest {

    MyFragment myFragment;

    @Before
    public void setUp(){
        myFragment = (MyFragment)FmyFragment.instantiate(ApplicationProvider.getApplicationContext(), MyFragment.class.getName());
        SupportFragmentTestUtil.startVisibleFragment(myFragment);
    }

}

But the line

SupportFragmentTestUtil.startVisibleFragment(myFragment);

is throwing the following exception:

java.lang.IllegalStateException: Recursive entry to executePendingTransactions

Did I miss something in my setup? I've tried many things and this is the closest I've been to starting my fragment with roboelectric.

If you need more info, feel free to ask.

Aucun commentaire:

Enregistrer un commentaire