View Javadoc
1   package org.apache.maven.plugins.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 java.util.ArrayList;
23  import java.util.List;
24  
25  /**
26   *
27   */
28  public final class ReportTestSuite
29  {
30      private final List<ReportTestCase> testCases = new ArrayList<ReportTestCase>();
31  
32      private int numberOfErrors;
33  
34      private int numberOfFailures;
35  
36      private int numberOfSkipped;
37  
38      private int numberOfFlakes;
39  
40      private Integer numberOfTests;
41  
42      private String name;
43  
44      private String fullClassName;
45  
46      private String packageName;
47  
48      private float timeElapsed;
49  
50      public List<ReportTestCase> getTestCases()
51      {
52          return testCases;
53      }
54  
55      public int getNumberOfErrors()
56      {
57          return numberOfErrors;
58      }
59  
60      public ReportTestSuite setNumberOfErrors( int numberOfErrors )
61      {
62          this.numberOfErrors = numberOfErrors;
63          return this;
64      }
65  
66      public ReportTestSuite incrementNumberOfErrors()
67      {
68          ++numberOfErrors;
69          return this;
70      }
71  
72      public int getNumberOfFailures()
73      {
74          return numberOfFailures;
75      }
76  
77      public ReportTestSuite setNumberOfFailures( int numberOfFailures )
78      {
79          this.numberOfFailures = numberOfFailures;
80          return this;
81      }
82  
83      public ReportTestSuite incrementNumberOfFailures()
84      {
85          ++numberOfFailures;
86          return this;
87      }
88  
89      public int getNumberOfSkipped()
90      {
91          return numberOfSkipped;
92      }
93  
94      public ReportTestSuite setNumberOfSkipped( int numberOfSkipped )
95      {
96          this.numberOfSkipped = numberOfSkipped;
97          return this;
98      }
99  
100     public ReportTestSuite incrementNumberOfSkipped()
101     {
102         ++numberOfSkipped;
103         return this;
104     }
105 
106     public int getNumberOfFlakes()
107     {
108         return numberOfFlakes;
109     }
110 
111     public ReportTestSuite setNumberOfFlakes( int numberOfFlakes )
112     {
113         this.numberOfFlakes = numberOfFlakes;
114         return this;
115     }
116 
117     public ReportTestSuite incrementNumberOfFlakes()
118     {
119         ++numberOfFlakes;
120         return this;
121     }
122 
123     public int getNumberOfTests()
124     {
125         if ( numberOfTests != null )
126         {
127             return numberOfTests;
128         }
129         if ( testCases != null )
130         {
131             return testCases.size();
132         }
133         return 0;
134     }
135 
136     public ReportTestSuite setNumberOfTests( int numberOfTests )
137     {
138         this.numberOfTests = numberOfTests;
139         return this;
140     }
141 
142     public String getName()
143     {
144         return name;
145     }
146 
147     public ReportTestSuite setName( String name )
148     {
149         this.name = name;
150         return this;
151     }
152 
153     public String getFullClassName()
154     {
155         return fullClassName;
156     }
157 
158     public ReportTestSuite setFullClassName( String fullClassName )
159     {
160         this.fullClassName = fullClassName;
161         int lastDotPosition = fullClassName.lastIndexOf( "." );
162         name = fullClassName.substring( lastDotPosition + 1, fullClassName.length() );
163         packageName = lastDotPosition == -1 ? "" : fullClassName.substring( 0, lastDotPosition );
164         return this;
165     }
166 
167     public String getPackageName()
168     {
169         return packageName;
170     }
171 
172     public ReportTestSuite setPackageName( String packageName )
173     {
174         this.packageName = packageName;
175         return this;
176     }
177 
178     public float getTimeElapsed()
179     {
180         return this.timeElapsed;
181     }
182 
183     public ReportTestSuite setTimeElapsed( float timeElapsed )
184     {
185         this.timeElapsed = timeElapsed;
186         return this;
187     }
188 
189     ReportTestSuite setTestCases( List<ReportTestCase> testCases )
190     {
191         this.testCases.clear();
192         this.testCases.addAll( testCases );
193         return this;
194     }
195 
196     /**
197      * {@inheritDoc}
198      */
199     public String toString()
200     {
201         return fullClassName + " [" + getNumberOfTests() + "/" + getNumberOfFailures() + "/"
202             + getNumberOfErrors() + "/" + getNumberOfSkipped() + "]";
203     }
204 }