FoamMain { void logEvent(Context context, String event){ if(eventTracker != null) { eventTracker.trackEvent(context, event); } } FoamMain(Context context);   }
@Test public void testLogEvent() { FoamMain foamMain = new FoamMain(null); EventTracker mockEventTracker = mock(EventTracker.class); foamMain.eventTracker = mockEventTracker; foamMain.logEvent(null, "test_event"); verify(mockEventTracker).trackEvent(any(Context.class), eq("test_event")); }