@Test public void shouldHandleFailIfNoTests() throws Exception { RunResult summary = new RunResult( 0, 0, 0, 0 ); try { Mojo plugin = new Mojo(); plugin.setFailIfNoTests( true ); reportExecution( plugin, summary, null, null ); } catch ( MojoFailureException e ) { assertThat( e.getLocalizedMessage() ) .isEqualTo( "No tests were executed! (Set -DfailIfNoTests=false to ignore this error.)" ); return; } fail( "Expected MojoFailureException with message " + "'No tests were executed! (Set -DfailIfNoTests=false to ignore this error.)'" ); }
public static void reportExecution( SurefireReportParameters reportParameters, RunResult result, PluginConsoleLogger log, Exception firstForkException ) throws MojoFailureException, MojoExecutionException { if ( firstForkException == null && !result.isTimeout() && result.isErrorFree() ) { if ( result.getCompletedCount() == 0 && failIfNoTests( reportParameters ) ) { throw new MojoFailureException( "No tests were executed! " + "(Set -DfailIfNoTests=false to ignore this error.)" ); } return; } if ( reportParameters.isTestFailureIgnore() ) { log.error( createErrorMessage( reportParameters, result, firstForkException ) ); } else { throwException( reportParameters, result, firstForkException ); } }
SurefireHelper { public static void reportExecution( SurefireReportParameters reportParameters, RunResult result, PluginConsoleLogger log, Exception firstForkException ) throws MojoFailureException, MojoExecutionException { if ( firstForkException == null && !result.isTimeout() && result.isErrorFree() ) { if ( result.getCompletedCount() == 0 && failIfNoTests( reportParameters ) ) { throw new MojoFailureException( "No tests were executed! " + "(Set -DfailIfNoTests=false to ignore this error.)" ); } return; } if ( reportParameters.isTestFailureIgnore() ) { log.error( createErrorMessage( reportParameters, result, firstForkException ) ); } else { throwException( reportParameters, result, firstForkException ); } } }
SurefireHelper { public static void reportExecution( SurefireReportParameters reportParameters, RunResult result, PluginConsoleLogger log, Exception firstForkException ) throws MojoFailureException, MojoExecutionException { if ( firstForkException == null && !result.isTimeout() && result.isErrorFree() ) { if ( result.getCompletedCount() == 0 && failIfNoTests( reportParameters ) ) { throw new MojoFailureException( "No tests were executed! " + "(Set -DfailIfNoTests=false to ignore this error.)" ); } return; } if ( reportParameters.isTestFailureIgnore() ) { log.error( createErrorMessage( reportParameters, result, firstForkException ) ); } else { throwException( reportParameters, result, firstForkException ); } } private  SurefireHelper(); }
SurefireHelper { public static void reportExecution( SurefireReportParameters reportParameters, RunResult result, PluginConsoleLogger log, Exception firstForkException ) throws MojoFailureException, MojoExecutionException { if ( firstForkException == null && !result.isTimeout() && result.isErrorFree() ) { if ( result.getCompletedCount() == 0 && failIfNoTests( reportParameters ) ) { throw new MojoFailureException( "No tests were executed! " + "(Set -DfailIfNoTests=false to ignore this error.)" ); } return; } if ( reportParameters.isTestFailureIgnore() ) { log.error( createErrorMessage( reportParameters, result, firstForkException ) ); } else { throwException( reportParameters, result, firstForkException ); } } private  SurefireHelper(); @Nonnull static String replaceThreadNumberPlaceholders( @Nonnull String argLine, int threadNumber ); static File replaceForkThreadsInPath( File path, int replacement ); static String[] getDumpFilesToPrint(); static void reportExecution( SurefireReportParameters reportParameters, RunResult result,
                                        PluginConsoleLogger log, Exception firstForkException ); static List<CommandLineOption> commandLineOptions( MavenSession session, PluginConsoleLogger log ); static void logDebugOrCliShowErrors( String s, PluginConsoleLogger log, Collection<CommandLineOption> cli ); static String escapeToPlatformPath( String path ); }
SurefireHelper { public static void reportExecution( SurefireReportParameters reportParameters, RunResult result, PluginConsoleLogger log, Exception firstForkException ) throws MojoFailureException, MojoExecutionException { if ( firstForkException == null && !result.isTimeout() && result.isErrorFree() ) { if ( result.getCompletedCount() == 0 && failIfNoTests( reportParameters ) ) { throw new MojoFailureException( "No tests were executed! " + "(Set -DfailIfNoTests=false to ignore this error.)" ); } return; } if ( reportParameters.isTestFailureIgnore() ) { log.error( createErrorMessage( reportParameters, result, firstForkException ) ); } else { throwException( reportParameters, result, firstForkException ); } } private  SurefireHelper(); @Nonnull static String replaceThreadNumberPlaceholders( @Nonnull String argLine, int threadNumber ); static File replaceForkThreadsInPath( File path, int replacement ); static String[] getDumpFilesToPrint(); static void reportExecution( SurefireReportParameters reportParameters, RunResult result,
                                        PluginConsoleLogger log, Exception firstForkException ); static List<CommandLineOption> commandLineOptions( MavenSession session, PluginConsoleLogger log ); static void logDebugOrCliShowErrors( String s, PluginConsoleLogger log, Collection<CommandLineOption> cli ); static String escapeToPlatformPath( String path ); static final String DUMP_FILE_PREFIX; static final String DUMP_FILENAME_FORMATTER; static final String DUMPSTREAM_FILENAME_FORMATTER; static final String DUMPSTREAM_FILENAME; static final String DUMP_FILENAME; }