1   package org.apache.maven.surefire.report;
2   
3   /*
4    * Copyright 2006 The Apache Software Foundation.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *      http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  import junit.framework.TestCase;
20  
21  /**
22   * Test for AbstractConsoleReporter
23   * 
24   * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
25   * @version $Id: AbstractConsoleReporterTest.java 415196 2006-06-18 21:11:24Z carlos $
26   */
27  public class AbstractConsoleReporterTest
28      extends TestCase
29  {
30  
31      private AbstractConsoleReporter consoleReporter;
32  
33      private ReportEntry report;
34  
35      protected void setUp()
36          throws Exception
37      {
38          super.setUp();
39          report = new ReportEntry();
40          report.setGroup( "group" );
41          report.setName( "name" );
42      }
43  
44      protected void setConsoleReporter( AbstractConsoleReporter consoleReporter )
45      {
46          this.consoleReporter = consoleReporter;
47      }
48  
49      protected AbstractConsoleReporter getConsoleReporter()
50      {
51          return consoleReporter;
52      }
53  
54      public void testTestSetStarting()
55          throws Exception
56      {
57          consoleReporter.testSetStarting( report );
58      }
59  
60      public void testGetTestSetStartingMessage()
61          throws Exception
62      {
63          String message = AbstractConsoleReporter.getTestSetStartingMessage( report );
64          assertEquals( "Running name (of group)", message );
65  
66          report.setGroup( null );
67          message = AbstractConsoleReporter.getTestSetStartingMessage( report );
68          assertEquals( "Running name", message );
69      }
70  
71      public void testParseTestSetStartingMessage()
72          throws Exception
73      {
74          String message = "Running name (of group)";
75          ReportEntry actualReport = AbstractConsoleReporter.parseTestSetStartingMessage( message );
76          assertEquals( report, actualReport );
77  
78          report.setGroup( null );
79          message = "Running name";
80          actualReport = AbstractConsoleReporter.parseTestSetStartingMessage( message );
81          assertEquals( report, actualReport );
82      }
83  
84      public void testIsTestSetStartingMessage()
85          throws Exception
86      {
87          String message = "Running name (of group)";
88          assertTrue( AbstractConsoleReporter.isTestSetStartingMessage( message ) );
89  
90          message = "Running name";
91          assertTrue( AbstractConsoleReporter.isTestSetStartingMessage( message ) );
92  
93          message = "Xxxx";
94          assertFalse( AbstractConsoleReporter.isTestSetStartingMessage( message ) );
95      }
96  
97  }