How to use findViewById() in robolectric
I simply want to test with robolectric if a certain view is visible in a fragment. My unit test looks like this: ActivityController controller = Robolectric.buildActivity(FragmentActivity.class); FragmentActivity activity = (FragmentActivity) controller.create().start().resume().visible().get(); F fragment = new MyFragment(); activity.getSupportFragmentManager().beginTransaction() .add(fragment, FRAGMENT_TAG).commit(); View view = fragment.getView().findViewById(R.id.my_view); assertEquals(view.getVisibility(), View.VISIBLE); I'm using the latest android gradle plugin 1.1.3, robolectirc 2.4