Android Robolectric Support Fragment FragmentTestUtil

To use Android Support Fragment v4 in Robolectric 3.0 you must add gradle dependency in /app/build.gradle

testCompile 'org.robolectric:shadows-support-v4:3.0'

Then import into your Robolectric testing java class

import org.robolectric.shadows.support.v4.SupportFragmentTestUtil;

then you can create/start android support v4 fragments within your Robolectric testing java class for unit testing:

SupportFragmentTestUtil.startVisibleFragment(fragment);

Cross posted to StackOverflow Android Robolectric Support Fragment.


Posted

in

,

by

Tags: