How can I test fragments with Robolectric?

后端 未结 7 1138
萌比男神i
萌比男神i 2020-12-02 10:16

I know there is a Robolectric.shadowOf(Fragment) method and a ShadowFragment class, thought they aren\'t listed on the docs, but I can\'t make it w

7条回答
  •  长情又很酷
    2020-12-02 10:50

    SupportFragmentTestUtil.startFragment(fragment, AppCompatActivity::class.java)
    

    If the activity is extending AppCompatActivity

    This is using Kotlin

提交回复
热议问题