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  import junit.framework.TestCase;
23  
24  /**
25   * Test for AbstractConsoleReporter
26   *
27   * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
28   * @version $Id: AbstractConsoleReporterTestCase.java 1056406 2011-01-07 17:34:39Z krosenvold $
29   */
30  public abstract class AbstractConsoleReporterTestCase
31      extends TestCase
32  {
33  
34      private AbstractConsoleReporter consoleReporter;
35  
36      private ReportEntry report;
37  
38      protected void setUp()
39          throws Exception
40      {
41          super.setUp();
42          report = CategorizedReportEntry.nameGroup( "name", "group" );
43      }
44  
45      protected void setConsoleReporter( AbstractConsoleReporter consoleReporter )
46      {
47          this.consoleReporter = consoleReporter;
48      }
49  
50      protected AbstractConsoleReporter getConsoleReporter()
51      {
52          return consoleReporter;
53      }
54  
55      public void testTestSetStarting()
56          throws Exception
57      {
58          consoleReporter.testSetStarting( report );
59      }
60  
61      public void testGetTestSetStartingMessage()
62          throws Exception
63      {
64          String message = AbstractConsoleReporter.getTestSetStartingMessage( report );
65          assertEquals( "Running name (of group)", message );
66  
67          report = CategorizedReportEntry.nameGroup( "name", null );
68  
69          message = AbstractConsoleReporter.getTestSetStartingMessage( report );
70          assertEquals( "Running name", message );
71      }
72  
73      public void testParseTestSetStartingMessage()
74          throws Exception
75      {
76          String message = "Running name (of group)";
77          ReportEntry actualReport = AbstractConsoleReporter.parseTestSetStartingMessage( message );
78          assertEquals( report, actualReport );
79      }
80  
81      public void testIsTestSetStartingMessage()
82          throws Exception
83      {
84          String message = "Running name (of group)";
85          assertTrue( AbstractConsoleReporter.isTestSetStartingMessage( message ) );
86  
87          message = "Running name";
88          assertTrue( AbstractConsoleReporter.isTestSetStartingMessage( message ) );
89  
90          message = "Xxxx";
91          assertFalse( AbstractConsoleReporter.isTestSetStartingMessage( message ) );
92      }
93  
94  }