Testing Activity with a Fragment with Robolectric
问题 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