{"id":473,"date":"2015-10-04T11:44:32","date_gmt":"2015-10-04T11:44:32","guid":{"rendered":"http:\/\/installingcats.com\/?p=473"},"modified":"2015-10-04T11:44:32","modified_gmt":"2015-10-04T11:44:32","slug":"android-robolectric-support-fragment-fragmenttestutil","status":"publish","type":"post","link":"https:\/\/installingcats.com\/2015\/10\/04\/android-robolectric-support-fragment-fragmenttestutil\/","title":{"rendered":"Android Robolectric Support Fragment FragmentTestUtil"},"content":{"rendered":"

To use\u00a0Android Support Fragment v4 in\u00a0Robolectric 3.0 you must add gradle dependency in \/app\/build.gradle<\/p>\n

testCompile 'org.robolectric:shadows-support-v4:3.0'<\/pre>\n

Then import into your Robolectric testing java class<\/p>\n

import org.robolectric.shadows.support.v4.SupportFragmentTestUtil;<\/pre>\n

then you can create\/start android support v4 fragments within your Robolectric testing java class for unit testing:<\/p>\n

SupportFragmentTestUtil.startVisibleFragment(fragment);<\/pre>\n

Cross posted to StackOverflow Android Robolectric Support Fragment<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"

To use\u00a0Android Support Fragment v4 in\u00a0Robolectric 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.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[28,29],"tags":[245],"_links":{"self":[{"href":"https:\/\/installingcats.com\/wp-json\/wp\/v2\/posts\/473"}],"collection":[{"href":"https:\/\/installingcats.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/installingcats.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/installingcats.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/installingcats.com\/wp-json\/wp\/v2\/comments?post=473"}],"version-history":[{"count":0,"href":"https:\/\/installingcats.com\/wp-json\/wp\/v2\/posts\/473\/revisions"}],"wp:attachment":[{"href":"https:\/\/installingcats.com\/wp-json\/wp\/v2\/media?parent=473"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/installingcats.com\/wp-json\/wp\/v2\/categories?post=473"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/installingcats.com\/wp-json\/wp\/v2\/tags?post=473"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}