### Question:
ViewBindingLifecycle { public void run(InflatedView inflatedView, BindingContext bindingContext) { inflatedView.bindChildViews(bindingContext); inflatedView.assertNoErrors(errorFormatter); if (bindingContext.shouldPreInitializeViews()) { inflatedView.preinitializeViews(bindingContext); } } ViewBindingLifecycle(ErrorFormatter errorFormatter); void run(InflatedView inflatedView, BindingContext bindingContext);  }### Answer:
@Test public void whenRunBindingLifeCycle_thenChildViewsShouldBeBound() { ViewBindingLifecycle lifecycle = new ViewBindingLifecycle(errorFormatter); lifecycle.run(inflatedView, bindingContext); verify(inflatedView).bindChildViews(bindingContext); }
@Test public void whenRunBindingLifeCycle_thenViewInflationErrorsShouldBeAsserted() { ViewBindingLifecycle lifecycle = new ViewBindingLifecycle(errorFormatter); lifecycle.run(inflatedView, bindingContext); verify(inflatedView).assertNoErrors(errorFormatter); }
@Test public void whenInflateAndBindWithPreInitalizingViews_thenChildViewsShouldBePreInitialized() { when(bindingContext.shouldPreInitializeViews()).thenReturn(true); ViewBindingLifecycle lifecycle = new ViewBindingLifecycle(errorFormatter); lifecycle.run(inflatedView, bindingContext); verify(inflatedView).preinitializeViews(bindingContext); }
@Test public void whenInflateAndBindWithoutPreInitalizingViews_thenChildViewsShouldBePreInitialized() { when(bindingContext.shouldPreInitializeViews()).thenReturn(false); ViewBindingLifecycle lifecycle = new ViewBindingLifecycle(errorFormatter); lifecycle.run(inflatedView, bindingContext); verify(inflatedView, never()).preinitializeViews(bindingContext); }