@Before
 public void setUp() throws Exception {
   activity = new TestFragmentActivity();
   activity.onCreate(null);
   manager = (TestFragmentManager) activity.getSupportFragmentManager();
   fragment = new TestFragment();
   containerView = (ViewGroup) activity.findViewById(CONTAINER_VIEW_ID);
 }
  @Test
  public void startFragment_shouldInsertTheFragmentViewIntoTheContainerView() throws Exception {
    manager.addFragment(CONTAINER_VIEW_ID, null, fragment, false);
    manager.startFragment(fragment);

    View fragmentViewParent =
        (View) activity.findViewById(TestFragment.FRAGMENT_VIEW_ID).getParent();
    assertThat(
        activity.findViewById(TestFragment.FRAGMENT_VIEW_ID),
        sameInstance(fragment.onCreateViewReturnValue));
    assertThat(fragmentViewParent, sameInstance((View) containerView));
  }
  @Test
  public void startFragment_shouldCallLifecycleMethods() throws Exception {
    manager.addFragment(View.NO_ID, null, fragment, false);
    fragment.transcript.clear();
    manager.startFragment(fragment);

    fragment.transcript.assertEventsSoFar(
        "onCreateView", "onViewCreated", "onActivityCreated", "onStart");

    assertEquals(fragment.onCreateViewInflater, activity.getLayoutInflater());
    assertNotNull(fragment.getView());
  }