View Javadoc
1   package org.apache.maven.plugin.surefire.report;
2   /*
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   *     http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing,
14   * software distributed under the License is distributed on an
15   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16   * KIND, either express or implied.  See the License for the
17   * specific language governing permissions and limitations
18   * under the License.
19   */
20  
21  import org.apache.maven.surefire.report.ReportEntry;
22  import org.apache.maven.surefire.report.SimpleReportEntry;
23  
24  import junit.framework.TestCase;
25  
26  /**
27   * @author Kristian Rosenvold
28   */
29  public class WrappedReportEntryTest
30      extends TestCase
31  {
32  
33      public void testClassNameOnly()
34          throws Exception
35      {
36          String category = "surefire.testcase.JunitParamsTest";
37          WrappedReportEntry wr =
38              new WrappedReportEntry( new SimpleReportEntry( "fud", category ), null, 12, null, null );
39          final String reportName = wr.getReportName();
40          assertEquals( "surefire.testcase.JunitParamsTest", reportName );
41      }
42  
43      public void testRegular()
44      {
45          ReportEntry reportEntry = new SimpleReportEntry( "fud", "testSum(surefire.testcase.NonJunitParamsTest)" );
46          WrappedReportEntry wr = new WrappedReportEntry( reportEntry, null, 12, null, null );
47          final String reportName = wr.getReportName();
48          assertEquals( "testSum", reportName );
49      }
50  
51      public void testGetReportNameWithParams()
52          throws Exception
53      {
54          String category = "[0] 1\u002C 2\u002C 3 (testSum)(surefire.testcase.JunitParamsTest)";
55          ReportEntry reportEntry = new SimpleReportEntry( "fud", category );
56          WrappedReportEntry wr = new WrappedReportEntry( reportEntry, null, 12, null, null );
57          final String reportName = wr.getReportName();
58          assertEquals( "[0] 1, 2, 3 (testSum)", reportName );
59      }
60  
61      public void testElapsed()
62          throws Exception
63      {
64          String category = "[0] 1\u002C 2\u002C 3 (testSum)(surefire.testcase.JunitParamsTest)";
65          ReportEntry reportEntry = new SimpleReportEntry( "fud", category );
66          WrappedReportEntry wr = new WrappedReportEntry( reportEntry, null, 12, null, null );
67          String elapsedTimeSummary = wr.getElapsedTimeSummary();
68          assertEquals( "[0] 1, 2, 3 (testSum)(surefire.testcase.JunitParamsTest)  Time elapsed: 0.012 s",
69                        elapsedTimeSummary );
70      }
71  
72  
73  }