EchoMojo extends AbstractMojo { void echo() throws MojoFailureException { try { echoPlugin.echo(); } catch (FailureException fex) { new ExceptionHandler(fex).throwMojoFailureException(); } }  @Override void execute();  }
@Test public void mavenEchoShouldRunEchoPlugin() throws Exception { EchoPlugin echoPlugin = mock(EchoPlugin.class); new ReflectionHelper(echoMojo).setField(echoPlugin); echoMojo.echo(); verify(echoPlugin).echo(); }
@Test public void exceptionInEchoShouldBeConverted() throws Exception { EchoPlugin echoPlugin = mock(EchoPlugin.class); doThrow(new FailureException("Gurka")).when(echoPlugin).echo(); new ReflectionHelper(echoMojo).setField(echoPlugin); expectedException.expect(MojoFailureException.class); expectedException.expectMessage(is("Gurka")); echoMojo.echo(); }