Testing Activity with a Fragment with Robolectric

谁都会走 提交于 2019-12-13 05:19:59

问题


I want to check if the Activity I create in a test is showing a Fragment. How can I do this? I've tried searching through Stack Overflow and Google but I couldn't find anything.


回答1:


You need to find the fragment by id with

activity.getFragmentManager.findFragmentById(R.id.your_fragment_container);

If this returns something different from null, then it means that your container has a Fragment.



来源:https://stackoverflow.com/questions/33811580/testing-activity-with-a-fragment-with-robolectric

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!