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<>();
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         return numberOfTests == null ? testCases.size() : numberOfTests;
126     }
127 
128     public ReportTestSuite setNumberOfTests( int numberOfTests )
129     {
130         this.numberOfTests = numberOfTests;
131         return this;
132     }
133 
134     public String getName()
135     {
136         return name;
137     }
138 
139     public ReportTestSuite setName( String name )
140     {
141         this.name = name;
142         return this;
143     }
144 
145     public String getFullClassName()
146     {
147         return fullClassName;
148     }
149 
150     public ReportTestSuite setFullClassName( String fullClassName )
151     {
152         this.fullClassName = fullClassName;
153         int lastDotPosition = fullClassName.lastIndexOf( "." );
154         name = fullClassName.substring( lastDotPosition + 1, fullClassName.length() );
155         packageName = lastDotPosition == -1 ? "" : fullClassName.substring( 0, lastDotPosition );
156         return this;
157     }
158 
159     public String getPackageName()
160     {
161         return packageName;
162     }
163 
164     public ReportTestSuite setPackageName( String packageName )
165     {
166         this.packageName = packageName;
167         return this;
168     }
169 
170     public float getTimeElapsed()
171     {
172         return this.timeElapsed;
173     }
174 
175     public ReportTestSuite setTimeElapsed( float timeElapsed )
176     {
177         this.timeElapsed = timeElapsed;
178         return this;
179     }
180 
181     ReportTestSuite setTestCases( List<ReportTestCase> testCases )
182     {
183         this.testCases.clear();
184         this.testCases.addAll( testCases );
185         return this;
186     }
187 
188     /**
189      * {@inheritDoc}
190      */
191     @Override
192     public String toString()
193     {
194         return fullClassName + " [" + getNumberOfTests() + "/" + getNumberOfFailures() + "/"
195             + getNumberOfErrors() + "/" + getNumberOfSkipped() + "]";
196     }
197 }