EchoMojo extends AbstractMojo { @Override public void execute() throws MojoFailureException { initLoggers(); if (skip) { mavenLogger.info("Skipping echo-maven-plugin"); } else { setup(); echo(); } }  @Override void execute();  }
@Test public void noMessageShouldGenerateException() throws Exception { expectedException.expect(MojoFailureException.class); expectedException.expectMessage("There was nothing to output. Specify either message or fromFile"); echoMojo.execute(); verifyNoMoreInteractions(mavenLoggerMock); verifyNoMoreInteractions(mavenEchoOutputMock); }
@Test public void skipShouldOnlyOutputMessage() throws Exception { new ReflectionHelper(echoMojo).setField("skip", true); new ReflectionHelper(echoMojo, AbstractMojo.class).setField(pluginLogMock); echoMojo.execute(); verify(pluginLogMock).info("Skipping echo-maven-plugin"); }
@Test public void executeShouldOutputMessage() throws Exception { new ReflectionHelper(echoMojo).setField("message", "Björn"); new ReflectionHelper(echoMojo, AbstractMojo.class).setField(pluginLogMock); echoMojo.execute(); verify(pluginLogMock).info("Björn"); verifyNoMoreInteractions(pluginLogMock); }