### Question:
ViewController implements ViewTreeObserver.OnGlobalLayoutListener, ViewGroup.OnHierarchyChangeListener { @VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE) public void ensureViewIsCreated() { getView(); } ViewController(Activity activity, String id, YellowBoxDelegate yellowBoxDelegate, Options initialOptions); boolean isDestroyed(); void setWaitForRender(Bool waitForRender); void addOnAppearedListener(Runnable onAppearedListener); void removeOnAppearedListener(Runnable onAppearedListener); void setViewVisibilityListener(ViewVisibilityListener viewVisibilityListener); @VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE) void ensureViewIsCreated(); boolean handleBack(CommandListener listener); @CheckResult Options resolveCurrentOptions(); @CheckResult Options resolveCurrentOptions(Options defaultOptions); @CallSuper void mergeOptions(Options options); @CallSuper void applyOptions(Options options); void setDefaultOptions(Options defaultOptions); Activity getActivity(); @VisibleForTesting(otherwise = VisibleForTesting.PROTECTED) ParentController getParentController(); void setParentController(@NonNull final ParentController parentController); void performOnParentStack(Func1<StackController> task); T getView(); void detachView(); void attachView(ViewGroup parent, int index); String getId(); @Nullable ViewController findController(String id); boolean containsComponent(Component component); void onViewWillAppear(); @CallSuper void onViewAppeared(); void onViewWillDisappear(); @CallSuper void onViewDisappear(); @CallSuper void destroy(); @Override void onGlobalLayout(); @Override void onChildViewAdded(View parent, View child); @Override void onChildViewRemoved(View view, View view1); abstract void sendOnNavigationButtonPressed(String buttonId); boolean isViewShown(); boolean isRendered(); List<Element> getElements(); public Options initialOptions; public Options options; }### Answer:
@Test public void ensureViewIsCreated() { ViewController spy = spy(uut); verify(spy, times(0)).getView(); spy.ensureViewIsCreated(); verify(spy, times(1)).getView(); }