Junit Testing In Android - Dialogfragment
I have a button in a FragmentActivity which, when pressed should open a DialogFragment. I want to test that it works using JUnit for Android in Eclipse. With an Activity I could us
Solution 1:
Assuming you are opening your dialog fragment sort of like this:
DialogFragmentdlg= YourDialogFragment.newInstance(..);
dlg.show(getFragmentManager(), "yourDialogTag");
you can check that it's up & showing by doing this in your test case:
// Click stuff on the UI-thread
getInstrumentation().waitForIdleSync();
Fragmentdialog= getActivity().getFragmentManager().findFragmentByTag("yourDialogTag");
assertTrue(dialog instanceof DialogFragment);
assertTrue(((DialogFragment) dialog).getShowsDialog());
Post a Comment for "Junit Testing In Android - Dialogfragment"