1 package org.apache.maven.surefire.report;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import java.io.BufferedOutputStream;
20 import java.io.OutputStreamWriter;
21 import java.io.PrintWriter;
22
23 public class ConsoleReporter
24 extends AbstractReporter
25 {
26 protected static final int BUFFER_SIZE = 4096;
27
28 protected PrintWriter writer;
29
30 protected long batteryStartTime;
31
32 public ConsoleReporter()
33 {
34 writer = new PrintWriter( new OutputStreamWriter( new BufferedOutputStream( System.out, BUFFER_SIZE ) ) );
35 }
36
37
38
39
40
41 public void println( String message )
42 {
43 writer.println( message );
44
45 writer.flush();
46 }
47
48 public void print( String message )
49 {
50 writer.print( message );
51
52 writer.flush();
53 }
54
55
56
57
58
59 public void runStarting( int testCount )
60 {
61 println( "" );
62 println( "-------------------------------------------------------" );
63 println( " T E S T S" );
64 println( "-------------------------------------------------------" );
65 }
66
67 public void runAborted( ReportEntry report )
68 {
69 println( "RUN ABORTED" );
70 println( report.getSource().getClass().getName() );
71 println( report.getName() );
72 println( report.getMessage() );
73 println( report.getThrowable().getMessage() );
74 }
75 public void batteryAborted( ReportEntry report )
76 {
77 println( "BATTERY ABORTED" );
78 println( report.getSource().getClass().getName() );
79 println( report.getName() );
80 println( report.getMessage() );
81 println( report.getThrowable().getMessage() );
82 }
83
84
85
86
87
88 public void batteryStarting( ReportEntry report )
89 throws Exception
90 {
91 batteryStartTime = System.currentTimeMillis();
92
93 println( "[surefire] Running " + report.getName() );
94 }
95
96 public void batteryCompleted( ReportEntry report )
97 {
98 long runTime = System.currentTimeMillis() - batteryStartTime;
99
100 print( "[surefire] Tests run: " + completedCount +
101 ", Failures: " + failures +
102 ", Errors: " + errors +
103 ", Time elapsed: " + elapsedTimeAsString( runTime ) + " sec" );
104
105 if ( failures > 0 || errors > 0 )
106 {
107 writer.print( " <<<<<<<< FAILURE !! " );
108 }
109
110 writer.println( "" );
111
112 writer.flush();
113
114 completedCount = 0;
115
116 errors = 0;
117
118 failures = 0;
119 }
120 }