1 package org.apache.maven.plugin.surefire;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.plugin.MojoFailureException;
23 import org.apache.maven.plugin.logging.Log;
24 import org.apache.maven.surefire.booter.ProviderConfiguration;
25
26
27
28
29 public final class SurefireHelper
30 {
31
32
33
34
35 private SurefireHelper()
36 {
37 throw new IllegalAccessError( "Utility class" );
38 }
39
40 public static void reportExecution( SurefireReportParameters reportParameters, int result, Log log )
41 throws MojoFailureException
42 {
43 if ( result == 0 )
44 {
45 return;
46 }
47
48 String msg;
49
50 if ( result == ProviderConfiguration.NO_TESTS_EXIT_CODE )
51 {
52 if ( ( reportParameters.getFailIfNoTests() == null ) || !reportParameters.getFailIfNoTests().booleanValue() )
53 {
54 return;
55 }
56
57 throw new MojoFailureException(
58 "No tests were executed! (Set -DfailIfNoTests=false to ignore this error.)" );
59 }
60 else
61 {
62
63 msg = "There are test failures.\n\nPlease refer to " + reportParameters.getReportsDirectory()
64 + " for the individual test results.";
65
66 }
67
68 if ( reportParameters.isTestFailureIgnore() )
69 {
70 log.error( msg );
71 }
72 else
73 {
74 throw new MojoFailureException( msg );
75 }
76 }
77 }