@Test public void shouldReportExceptionThrownOnStart() throws Exception { final RuntimeException expectedException = new RuntimeException(); Mockito.doThrow(expectedException).when(mockAgent).onStart(); invoker.start(); invoker.invoke(); verify(mockAgent, never()).doWork(); verify(mockErrorHandler).onError(expectedException); verify(mockAgent).onClose(); assertTrue(invoker.isStarted()); assertFalse(invoker.isRunning()); assertTrue(invoker.isClosed()); }