View Javadoc

1   package org.apache.maven.surefire.report;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *     http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  /**
23   * Surefire reporter that will prefix surefire output to make it easier to parse when forking tests
24   *
25   * @version $Id: ForkingConsoleReporter.java 1063892 2011-01-26 22:04:57Z krosenvold $
26   */
27  public class ForkingConsoleReporter
28      extends ConsoleReporter
29  {
30      /**
31       * Surefire output lines not part of header or footer, nor test output will start with this value.
32       * eg. "Running org.foo.BarTest" or "Tests run: ..."
33       */
34      public static final String FORKING_PREFIX_STANDARD = "@SL";
35  
36      /**
37       * Surefire output lines part of the header will start with this value
38       */
39      public static final String FORKING_PREFIX_HEADING = "@HL";
40  
41      /**
42       * Surefire output lines part of the footer will start with this value
43       */
44      public static final String FORKING_PREFIX_FOOTER = "@FL";
45  
46      public ForkingConsoleReporter( ReporterConfiguration reporterConfiguration )
47      {
48          super( reporterConfiguration );
49      }
50  
51      /**
52       * Write a header line prepending {@link #FORKING_PREFIX_HEADING}
53       */
54      void writeHeading( String message )
55      {
56          writer.print( FORKING_PREFIX_HEADING );
57  
58          super.writeHeading( message );
59      }
60  
61      /**
62       * Write a footer line prepending {@link #FORKING_PREFIX_FOOTER}
63       */
64      public void writeFooter( String footer )
65      {
66          writer.print( FORKING_PREFIX_FOOTER );
67  
68          // Deliberately set to writeMessage
69          super.writeMessage( footer );
70      }
71  
72      /**
73       * Write a surefire message line prepending {@link #FORKING_PREFIX_STANDARD}
74       */
75      public void writeMessage( String message )
76      {
77          writer.print( FORKING_PREFIX_STANDARD );
78  
79          super.writeMessage( message );
80      }
81  }