How to check in robolectric did I open a fragment when I click a button?

I have several buttons, when I click on them I open different fragments of the dialog. I want to know how to check if a dialog is open? or if it opens, is this the correct type?

Please, help. Thanks in advance.

+4
source share
2 answers

Well, I figured it out myself. From this very good tutorial by Colin Miller (@LinkedIn software development engineer), I can solve it.

https://www.youtube.com/watch?v=UEklodQTJZY

This question may not be very helpful, but this tutorial is definitely useful.


The solution to this problem:

button.performClick()

XDialogFragment dialog = (XDialogFragment) activity
                .getFragmentManager().findFragmentByTag(XDialogFragment.TAG);

Assert.assertNotNull(dialog);
+5
source
+1

All Articles